The Periodic Table is arranged in columns called groups and rows called periods. Metals are found on the left and in the centre of the table. Non-metals are found on the right.
The position of an element comes from the electrons in its atoms. Electrons sit in shells around the nucleus, and the outer shell matters most for bonding. For the elements in Groups 1 to 7, the group number is the number of electrons in the outer shell. Metal atoms usually have one, two or three outer electrons. Magnesium is in Group 2, so its atoms have two outer electrons. Metal atoms lose these electrons, which leaves a full shell underneath, and they become positive ions. The nucleus does not change when this happens.
Non-metal atoms usually have four to seven outer electrons. Fluorine and chlorine are in Group 7, so their atoms have seven outer electrons. They gain one electron to fill the outer shell and become negative ions, or they share electrons with other atoms. The elements in Group 0 already have a full outer shell, so they are unreactive.