Hydrocarbons , any of a class of organic chemical compounds composed only of the elements carbon (C) and hydrogen (H). The carbon atoms join together to form the framework of the compound, and the hydrogen atoms attach to them in many different configurations. Hydrocarbons are the principal constituents of pertrolium and natural gas. They serve as fuels and lubricants as well as raw materials for the production of plastics , fibers, rubbers, solvents, explosives , and industrial chemicals.