Yes, all fossil fuels are composed of hydrocarbons i.e. carbon and hydrogen. Fossil fuels were formed as a result of plants or animals that died millions of years ago and were buried inside the earth for a long period of time. Over millions of years, heat and pressure changed the dead organisms into fossil fuels. As the most abundant elements in the living organisms(Plants or animals) are carbon and hydrogen, that's why all fossil fuels are made up of compounds of carbon and hydrogen.