Fossil fuels are natural substances formed from the remains of ancient plants and animals. The main types are coal, oil, and natural gas. Coal forms over millions of years as dead plant matter is buried under layers of mud and compressed. Oil and natural gas also form from buried remains of ancient microorganisms. Fossil fuels are important energy sources and are used to generate electricity, for transportation, heating homes and more, but their extraction and accidents causing spills can significantly damage the environment.