The octet rule states that atoms are most stable when they have a full shell of electrons in the outside electron ring. The first shell has only two electrons in a single s subshell. Helium has a full shell, so it is stable, an inert element. Hydrogen, though, has only one electron. It can lose an electron to become H+, a hydrogen ion or it can gain an electron to become H-, a hydride ion. All the other shells have an s and a p subshell, giving them at least eight electrons on the outside. The s and p subshells often are the only valence electrons, thus the octet rule is named for the eight s and p electrons.
On the Periodic Chart with shell totals you can easily see the octet rule. A valence is a likely charge on an element ion. All of the Group 1 elements have one electron in the outside shell and they all have a valence of plus one. Group 1 elements will lose one and only one electron, that single outside electron to become a single positive ion with a full electron shell of eight electrons (an octet) in the s and p subshells under it.
Group 2 elements all have two electrons in the outer shell and all have a valence of plus two. Beryllium can be a bit different about this, but all other Group 2 elements can lose two electrons to become +2 ions. They do not lose only one electron, but two or none.
The Transition Elements, Lanthanides, and Actinides are all metals. Many of them have varying valences because they can trade around electrons from the outer shell to the inner d or f subshells that are not filled. For this reason they sometimes appear to violate the electron addition scheme.
Group 3 elements have a valence of plus three. Boron is a bit of an exception to this because it is so small it tends to bond covalently. Aluminum has a valence of +3, but some of the larger Group 3 elements have more than one valence.
The smallest Group 4 elements, carbon and silicon, are non-metals because the four electrons are difficult to lose the entire four electrons in the outer shell. Small Group 4 elements tend to make only covalent bonds, sharing electrons. Larger Group 4 elements have more than one valence, usually including +4.
Small Group 5 elements, nitrogen and phosphorus, are non-metals. They tend to either gain three electrons to make an octet or bond covalently. The larger Group 5 elements have more metallic character.
Small Group 6 elements, oxygen and sulfur, tend to either gain two electrons or bond covalently. The larger Group 6 elements have more metallic character.
Group 7 elements all have seven electrons in the outer shell and either gain one electron to become a -1 ion or they make one covalent bond. The Group 7 elements are diatomic gases due to the strong tendency to bond to each other with a covalent bond.
All of the inert elements, the noble gases, have a full octet in the outside shell (or two in the first shell) and so do not naturally combine chemically with other elements.