As opposed to ionic bonding in which a complete transfer of electrons occurs, covalent bonding occurs when two (or more) elements share electrons. Covalent bonding occurs because the atoms in the compound have a similar tendency for electrons (generally to gain electrons).