How do you make an element? Alchemists sadly discovered that it isn’t as easy as they’d hoped. But that’s not to say it is a complicated process: to build an element all you really need is energy. Lots and lots of energy.
Immediately following the big bang, there was abundant energy. In the first three minutes, a great deal of this condensed into protons and electrons, which combined to make hydrogen, the first element. Hydrogen is matter, and all matter experiences attraction to other matter by the force of gravity. A diffuse cloud of matter floating in space will coalesce to form a lump, a body, which is denser than the area around it. This body will continue to attract further material until its own gravitation force is strong enough to crush the matter at its core. And so, a star is born.
Matter does not crush easily, as nuclei (all of which have a positive charge) strongly repel each other, much in the way that two magnets repel one another. With enough force, however, the nuclei can be brought close enough together that repulsion turns to attraction (as the so-called ‘strong nuclear force’ overpowers the ‘electrostatic force’) and the nuclei snap together, much as if one of your magnets spun around to bring the poles into alignment.
The combination of nuclei is called nuclear fusion, and it is fusion that makes the stars glow so brightly. At the heart of small stars (like ours, the sun), four hydrogen atoms combine to produce helium, which is the second lightest element. Towards the end of their lives, small stars combine three helium atoms to create carbon atoms.
It takes a larger star to produce a larger element, and the most massive stars can produce elements as heavy as iron (the 26th element). But not further – why is this? An iron nucleus is the most stable nucleus possible: this is due to the way the particles that make up the nucleus are packed together. The 56 protons and neutrons in iron-56 fit so snugly together that the addition or removal of even a single particle makes it less stable. All elements that are heavier than iron can only be produced in supernovae (where conditions are much, much hotter).
Following the massive explosion of a supernova, the debris left over coalesces in space, forming further stars and planets. To paraphrase the great Carl Sagan: you, I, and everything around us is formed from stardust.