A molecule is the smallest unit of a chemical substance that still keeps the substance's properties. It forms when two or more atoms bond together by sharing electrons. Water (H₂O), oxygen (O₂), and carbon dioxide (CO₂) are everyday examples.
More precisely, IUPAC defines a molecule as an electrically neutral group of two or more atoms held together by covalent bonds. Under this strict definition, an isolated atom — like a single helium (He) or oxygen (O) atom — is not a molecule.
A molecule can have a small or large chain depending on the number of atoms linked.
For example, in the image below, a small molecule of methane is shown alongside an aldohexose sugar, a larger, long-chain molecule.

Any change in the attached atom will change the nature and the properties of the molecule. For example, joining two Cl atoms gives a Cl-Cl molecule. Changing the linkage to form an H-Cl bond gives a new molecule with entirely different properties.
Types of Molecules
Homonuclear vs. Heteronuclear
The molecules are classified into two types based on the type of atoms involved. If the atoms involved are of the same type, a homonuclear molecule is formed—for example, the Hydrogen (H2) molecule. If the atoms that combine to create a molecule are different, a heteronuclear molecule is formed—for example, a HCl molecule.

Polar vs. Nonpolar
When combining atoms are different or heteronuclear, it can create another subdivision of the molecule based on its polarity. In such cases, a molecule can also be classified as polar or nonpolar. A polar molecule has one positive end and another negative end, like in the HCl molecule. Compared to a molecule with no heteroatoms, such as H2, there is no such separation of charges, and the molecule is essentially nonpolar.

