Coal, being one of the major energy sources for power generation, contains several critical trace elements. There is a growing scarcity and expense of these critical elements as a result of the increased demand and limitation of mining sources. To explore the geochemical characteristics of the rare-metal, rare-dispersed (scattered), and rare-earth elements (TREs) in coal, 25 coal seam samples of the Shanxi Formation in the Huainan coalfield were collected. The major element oxides, minerals, and TREs were analyzed by X-ray fluorescence spectroscopy (XRF), X-ray diffraction (XRD), and inductively coupled plasma-mass spectrometry (ICP-MS). The results revealed that the coal of the Shanxi Formation had ultra-low moisture and low ash yield and was medium–high-volatility with low sulfur content and high calorific value. Concerning minerals, the coal was mainly composed of kaolinite, illite, quartz, calcite, dolomite, and pyrite. Compared with Chinese coal and world hard coal, rare-metal element Li and rare-dispersed element Se were enriched, whereas Ga and Ta were only slightly enriched. The average content of REYs was 51.34 μg/g, which is lower than the average content of REYs in Chinese coal. It has the enrichment characteristics of light REYs. In the vertical direction, the content of most TREs was higher in the roof and floor of the coal seam and the parting, indicating that the sedimentary microenvironment plays an important role in controlling the migration and enrichment of elements. The experimental results of sequential chemical extraction and correlation analysis showed that the TREs in the Shanxi Formation coal mainly exist in a residual and carbonate bound state, and occur in clay minerals and carbonate minerals. The enrichment of Se may be due to its high organic form ratio. The C-value, B content, w(Sr)/w(Ba), and REY geochemical parameters indicated that the Shanxi Formation Coal seam was developed in a transitional, semi-saline, deltaic sedimentary environment. With their development affected by seawater, REYs in coal are greatly supplied by terrigenous clastics. The complex sedimentary environment is an important reason for the varying occurrence states of TREs in the Shanxi Formation coals.