In electrolysis of a solution, if the non-metal contains oxygen then oxygen will be produced at the anode as the negative water ions formed from the ionisation of water are attracted to the anode. They lose electrons and form oxygen gas. If the non-metal ion is a halogen, the halogen gas is formed at the anode