Bonding in chemistry involves the transfer or sharing of electrons. In the case of ionic bonding, one or more electrons are transfered from one atom to another leading to charged fragments, one that is positively charged and the other is negatively charged. The two oppositely charged fragments are attracted to one another and the electrostatic force of attraction keeps the two fragments in close vicinity to one another. In covalent bonding, one or more electrons are shared between two atoms. Covalent bonding typically occurs with carbon atoms since they possess 4 electrons, and so they neither want to lose 4 electrons or gain 4 electrons to lead to a full outer shell of electrons. Therefore, carbon is happy to share its electrons with other atoms such as another carbon or hydrogen, oxygen, nitrogen, and several others. Ionic bonding typically happens with atoms that either need one or two electrons to achieve a full outer shell or they have one or two electrons already in their outer shell and are happy to lose the electron(s) to lead to a stable bond.