Coal is formed by the bacterial action on dead vegetation under high temperature and pressure in the absence of air.
The first stage in the formation of coal is peat. Peat is partially decayed plant matter that is formed due to the action of bacteria in the absence of air causing decomposition of the plant matter.
The second stage in the formation of coal is lignite. Lignite is formed when peat is subjected to increased heat and increased pressure from the soil above.
The third stage in the formation of coal is bituminous which is formed when lignite is further subjected to increased heat and increased pressure from the soil above.
Finally, the fourth stage in the formation of coal is anthracite which is formed when bituminous is further subjected to increased heat and increased pressure for a long period of time.
As these transformations from peat to anthracite takes place, the moisture content decreases and the carbon content increases with each stage.