When atoms share pairs of electrons, they form covalent bonds. These bonds between atoms are strong. A single line between two atoms in a diagram represents one shared pair of electrons. In oxygen, O2, the atoms share two pairs, so four electrons are shared and the bond is a double bond.
Some covalently bonded substances consist of small molecules, such as hydrogen, chlorine, oxygen, nitrogen, hydrogen chloride, water, ammonia and methane. You can recognise a small molecule from its formula, which has just a few non-metal atoms, such as H2O or NH3. Some substances have very large molecules, such as polymers. A polymer is drawn as a repeating unit in brackets with the letter n outside, where n is a large number.
Other covalent substances have giant covalent structures, such as diamond and silicon dioxide. In these, a huge network of atoms is joined by covalent bonds.
You can deduce a molecular formula by counting the atoms in a model. A molecule with one carbon atom bonded to four hydrogen atoms is methane, CH4, with five atoms in total. Each type of diagram has limits. Dot and cross diagrams show the outer electrons but not the shape of the molecule. Ball and stick models show the shape in three dimensions, but the sticks suggest solid rods between the atoms.