Hepatocellular carcinoma (HCC) is one of the most common malignancies with poor survival. Tumor tissues are heterogeneous, with different cell types in the tumor microenvironment, which play different roles in tumorigenesis and tumor progression attached to the prognosis of HCC.This study analyzed HCC RNA-seq for cell-type identification and prognosis by estimating relative subsets of RNA transcript (CIBERSORTx). Analyzing LIHC RNA-seq (n = 423) from TCGA showed that high infiltration of eosinophils promoted HCC progression.Interaction of B cells and macrophages in HCC was detected by the Hepa1-6 orthotopic transplantation mice model and flow cytometer analysis. B cells were correlated with macrophages (r=-0.24) and could affect the expression of PDL1 in macrophages infiltrating in LIHC. Transcription factor Zinc finger protein 296 (ZNF296) might accelerate HCC progression by regulating PAFAH1B3 and H2AFX. HCC patients with high expression of ZNF296 were in the late pathological stage. Moreover, the expression of ZNF296 was positively associated with the abundance of activated B cells (r = 0.185) and macrophages (r = 0.167). Among the survival and dead phenotype related to immune cells identified by SCISSOR analysis, T cells were most correlated to the excellent prognosis of HCC. The normal function of Liver cells and DC cells were also connected with the good prognosis of HCC.This investigation primarily delves into the intricate interplay between the immune microenvironment and the prognosis of HCC, thereby unveiling ZNF296 as a novel diagnostic and therapeutic target for HCC.