In the time right after the Big Bang, when the new universe was full of photons and bosons zipping around everywhere, some of the photons broke apart into electrons and anti-electrons called positrons. So you could think of an electron as the negative half of a photon. Most of these electrons and positrons eventually lost energy and hooked back up into photons again, but some of the positrons got lost somewhere, and their electrons were left on their own.
The electrons didn’t like being on their own, so they hooked up with some protons in the same situation, and these were the first hydrogen atoms. A hydrogen atom has just one proton and one electron, but soon the stars started to make more complicated atoms, with many protons and electrons, like oxygen, carbon, sulphur and iron.
Inside these more complicated atoms, the electrons don’t just rush around any which way. They stay inside specific areas of the atom, which we call shells. This is the easiest way for atoms to hold together, so that’s what they do. Each shell can only hold a certain number of electrons, like an egg carton can only hold a certain number of eggs. The first shell (the one closest to the protons at the center of the atom) can only hold two electrons. If there are more than two electrons, they have to start a second shell further away from the center. That second shell is bigger, and it can hold eight electrons. Uranium atoms, the biggest atoms in nature, have 92 electrons, and they need seven shells to hold them all.
Often an atom runs out of electrons when its outermost shell (what scientists call the valence shell) isn’t full. Oxygen atoms, for instance, have eight electrons. They fill up the inner shell with two electrons, and then there are only six electrons in the outer shell, which has room for eight electrons. Because of that, oxygen atoms join up easily with other atoms, like hydrogen, that also have spaces in their valence shells. The atoms form a molecule by sharing electrons, and they use these shared electrons to fill up their valence shells. The molecule becomes stronger and more stable than any of the individual atoms would have been on its own. When one oxygen atom combines with two hydrogen atoms (H2O), they make molecules of water.
Other atoms find it’s easier to give their electrons to another atom, rather than sharing the electron. Sodium, for instance, has only one lonely electron in its valence shell. If it could just get rid of that one electron, then it could get rid of that shell, and the next one in would be full. But chlorine has seven electrons in its valence shell, and it needs eight to fill it up. So whenever sodium gets near chlorine, the sodium atoms give their extra electron to the chlorine atoms. You might think they would then go on about their own business. But the electrons still hold onto their original atoms too, so the sodium and chlorine atoms form a molecule together called sodium chloride – or salt.