The chemical reactions and pathways involving any halogen, elements of Group VII; includes metabolism of halogen-containing compounds.