Coal is a hard rock which can be burned as a fossil fuel. It is mostly carbon but also contains hydrogen, sulphur, oxygen and nitrogen. It is a sedimentary rock formed from peat, by the pressure of rocks laid down later on top.
Peat, and therefore coal, is formed from the remains of plants which lived millions of years ago in tropical wetlands (coal swamps), such as those of the late Carboniferous period (the Pennsylvanian). Charcoal is made by wood heated in an airless space.