Valence electrons

The electrons in any atom can be divided into two types. These are:
core electrons in filled shells.  These electrons are not involved in bonding
valence (outer) electrons in unfilled shells.  These are the bonding electrons.
 
1 2
  1H 2He
3Li 4Be   5B 6C 7N 8O 9F 10Ne
11Na 12Mg 13Al 14Si 15P 16S 17Cl 18Ar
19K 20Ca 21Sc 22Ti 23V 24Cr 25Mn 26Fe 27Co 28Ni 29Cu 30Zn 31Ga 32Ge 33As 34Se 35Br 36Kr

The first four periods (rows) of the periodic table are shown.
These contain many important elements.

 
Mg (12 electrons) has
2 electrons in shell 1 (a filled shell)
8 electrons in shell 2 (a filled shell)
2 electrons in shell 3 (incomplete).

Hence Mg has 10 core electrons and 2 valence electrons.

The number of core electrons depends on the period (row) in which the element is found.

Elements in period 2 have 2 core electrons
(equal to the number of elements in period 1).
Elements in period 3 have 10 core electrons (equal to the number of elements in periods 1 and 2).
Elements in period 4 have 18 core electrons
(equal to the number of elements in periods 1, 2 and 3).
 
The Groups in the periodic table are the columns with numbers at the top.
The number of valence (outer) electrons on an atom can be deduced from its Group number.

For main group* elements the number of valence electrons equals the last digit of the Group Number.
*Main group elements are the elements in Groups 1 and 2 as well as the elements in Groups
to
.