Fossil fuels such as coal, oil, and natural gas were formed from the remains of dead plants and animals that lived millions of years ago. Coal is a hard, black rock formed from vegetation that grew in swampy areas 400 million years ago. Oil is formed from the remains of marine organisms and is used as fuel for transportation and manufacturing. Natural gas is composed mainly of methane and is used for heating, cooking, and electricity generation. Fossil fuels are extracted and refined for energy use but their extraction and use also carries environmental risks such as oil spills.