Coal is mostly carbon with variable amounts of other elements; chiefly hydrogen, sulfur, oxygen, and nitrogen. Coal is formed if dead plant matter decays into peat and over millions of years the heat and pressure of deep burial converts the peat into coal.