Valence electrons found in the s and p orbitals of the highest energy levels can be involved in bonding primarily in two basic ways.
Electrons can be released or accepted in order to complete the outer orbitals creating ions. These ions are then attracted to each other through electrochemical attractions to opposite charges causing atoms to bond in an ionic bond.
An example of this would be Magnesium Chloride.
Magnesium has an electron configuration of #1s^2 2s^2 2p^6 3s^2# the valence electrons are in the 3s orbital giving Magnesium 2 valence electrons. All atoms seek to follow the Rule of Octet having 8 valence electrons. Since it is easier for Magnesium to lose the 2 electrons than try to gain 6 electrons the Magnesium atom readily gives up the 2 electrons in the 3s orbital and becomes a positively charged cation of #Mg^(+2)#.
Chlorine has an electron configuration of #1s^2 2s^2 2p^6 3s^2 3p^5# the valence electrons are in the 3s and 3p orbitals giving Chlorine 7 valence electrons. All atoms seek to follow the Rule of Octet having 8 valence electrons. Since it is easier for Chlorine to gain the 1 electron than try to give up 7 electrons the Chlorine atom readily takes on 1 electron in the 3p orbital and becomes a negatively charged anion of #Cl^(-1)#.
It takes two negative Chlorine anions of #Cl^-1# to balance an equal and opposite charge of the positive cation of #Mg^(+2)# making the ionic compound #MgCl_2#.
The other possible way that valence electrons can be involved in bonding is by being shared by two atoms in order to complete the Rule of Octet in a Molecular (covalent) Bond.
When Carbon TetraChloride is formed, Carbon which has an electron configuration of of #1s^2 2s^2 2p2#, Carbon has 4 valence electrons. Therefore carbon needs to gain 4 electrons to complete the outer orbital.
Chlorine #1s^2 2s^2 2p^6 3s^2 3p^5# the valence electrons are in the 3s and 3p orbitals giving Chlorine 7 valence electrons. Chlorine needs one electron in each of the outer orbitals.
Four Chlorine will bond with one Carbon sharing one electron each. The molecular (covalent) compound become #C##Cl_4#, Each Chlorine and Carbon satisfy the Rule of Octet by this sharing of these electrons.