Mg is a member of alkaline earth metal
that is group ii elements. Alkaline earth metals are elements with two valence electrons in their outermost energy level. magnesium for example has electronic configuration of 2.8.2 or 1s^2 2s^2 2P^6 3S^2 or [Ne] 3s^2 has two valence electron in the outermost energy level that is 3S^2