Explain the term 'valency' of an element. How does it vary in a period and in a group in the periodic table?

The chemical properties of elements depend upon the number of electrons in the outer most shell
of an atom. These electrons are called valence
electrons and thus determines the valency of the
atom (or element).
In representative elements, the valency is generally equal to either n or (8 - n), where n is number of valence electrons in the atom.
In a period valence electrons increase from 0 to 8
on moving from left to right. The valency of an
element w.r.t. H and Cl increases from 1 to 4 and
then decreases to zero. However w.r.t. oxygen,
valency increases from 1 to 7 and then becomes
zero in noble gases.
In a group, the number of valence electrons re¬f mains the same and therefore all elements in a
group exhibit same valency e.g., all elements of
group I have valency one and those of group 2
have valency two. However the transition elements
exhibit variable valency