Fossil fuels like gas and oil are formed from animal and plant matter deeply buried by sediments. The animal and plant matter decays and over millions of years form oil and gas; if conditions are right, the oil and gas remain trapped below Earth’s surface. Coal forms from thick deposits of plant matter that accumulated in swampy areas. The decaying plants are under pressure from the thick layers of sediments that buried them; over time the plant matter forms coal.