In an ionic bond, one atom transfers electrons to the other. In a covalent bond, the two atoms share electrons.
In an ionic bond, the more electronegative atom takes atom takes electrons from the other atom. The electronegativity difference must be greater than 1.6 for this to happen.
For example, an Na atom can get a complete valence shell by losing an electron, A Cl atom can get a complete shell by gaining an electron.
The Na transfers an electron to a Cl, forming Na⁺ and Cl⁻ ions.
The ionic bonds consist of the electrostatic attractions between the oppositely charged ions.
In covalent bonding, the two atoms share the valence electrons between them to get to stable octet.
For example, the electronegativities of C and H are quite close, so one atom cannot take an electron from the other.
The atoms are forced to share electrons. C needs four electrons to complete its valence shell, and H needs one electron.
So four H atoms each share their one electron with a C atom. The compound formed is CH₄.
The C atom now has eight electrons in its valence shell, and each H atom has two electrons. Each has a complete valence shell.
The covalent bonds consist of the shared electron pairs between the nuclei.