Coal is a black or brownish black combustible mineral formed about 300 million years ago when the earth was covered by swampy forests of scale tress (lycopods) giant ferns, horsetails, and club mosses. Layer upon layer of these plants died and were compressed and then covered with soil. As the layers were successively covered their access to the air was limited and this stopped the full decomposition process creating peat. Over the years heat and pressure worked to force out oxygen and hydrogen, leaving carbon-rich deposits, called coal, in layers known as seams.
The carbon content of the coal rises as it is compressed further and the moisture content falls. The first type of coal to form is lignite, followed by subbituminous coal, bituminous coal and lastly anthracite. These grades of coal are known as ranks - read more about coal ranks.