A chemical compound is a substance composed of two or more different elements chemically bonded together in a fixed proportion by mass. When a compound is formed from its components, a chemical change takes place through chemical reactions. Elements form compounds to become more stable, which happens when the maximum number of possible electrons are in the outermost energy level (normally two or eight valence electrons).
Examples include water (H2O) and carbon dioxide (CO2). However, not all molecules are compounds. Compounds are pure substances that contain two or more elements combined in a definite fixed proportion. A diatomic molecule of hydrogen, though, represented by H2, is made of atoms of only one element and therefore is not regarded as a compound.