What rule do atoms that tend to combine in such a way that they have eight electrons in their valence shell follow ?
The rule is applicable to the main - group elements , especially carbon , nitrogen , oxygen , and the halogens , but also to metals such as sodium or magnesium .