How did the universe's elements form?
We all know the universe contains a vast array of elements, ranging from light gases, such as helium, to heavy metals, like lead. But where did all of the elements come from?
The journey of the elements starts in the earliest moments of the Big Bang, when our universe was only a few seconds to a few minutes old. At that time, the entire cosmos was crammed into a volume millions of times smaller than it is today. Due to the incredibly high densities, the average temperature of all the material in the universe was well over a billion degrees, which is more than hot enough for nuclear reactions to take place. In fact, it was so hot that even protons and neutrons could not exist as stable entities. Instead, the universe was just a sea of more fundamental particles, called quarks and gluons, seething in a raw plasma state.
But the universe would not stay that way for long. It was expanding, which means it was also cooling. Eventually, the quarks could bind together to form the first protons and neutrons without instantly getting demolished. Protons are ever so slightly lighter than neutrons, which gave them an edge in this initial phase of particle production. Once the universe was a few minutes old, it was far too cold to create new protons and neutrons. So those first heavy particles were the only ones the universe was ever going to make (outside of future rare high-energy interactions).
Related: The history of the universe: Big Bang to now in 10 easy steps
By the time the heavy particles finally froze out, there were roughly six protons for every neutron. Neutrons by themselves aren't stable; they decay with a half-life of around 880 seconds. Immediately, some of the neutrons began to decay away, while the remainder started binding with protons to form the first atomic nuclei. Of all the light elements, helium-4, which consists of two protons and two neutrons, has the largest binding energy, which means it's the easiest to form and the hardest to break apart. So almost all of that helium went into the production of helium-4.
From calculations like this, cosmologists can predict that the universe started out with a mixture of roughly 75% hydrogen (which is just a bare proton), 25% helium and a small scattering of lithium — which is exactly what astronomers observe.
Stellar nucleosynthesis
The next stage in the appearance of the elements had to wait for the first generation of stars, which didn't start shining until hundreds of millions of years after the Big Bang. Stars power themselves through nuclear fusion, transforming hydrogen into helium. This process leaves a tiny bit of energy left over. But stars have so much hydrogen available that they can burn for billions, or sometimes trillions, of years.
Near the ends of their lives, stars like the sun switch to fusing helium instead, turning it into carbon and oxygen before they die as planetary nebulae. This is why carbon and oxygen are so abundant in the universe; after hydrogen and helium, they are the most commonly produced elements. In fact, oxygen is the most common element on Earth, although most of it is bound up with silicates to form the ground beneath your feet.
More massive stars — those with at least eight times the mass of the sun — fuse even heavier elements in their cores. Especially in their final weeks, days and even hours, the most massive stars in the universe create nitrogen, neon, silicon, sulfur, magnesium, nickel, chromium and iron.
Aftermath nucleosynthesis
That's the end of the line for the formation of elements within stars. Their intense energies are perfectly capable of producing heavier elements, but fusing anything above iron saps energy, rather than producing it, so those heavier elements appear only rarely in the cores of massive stars.
Instead, the rest of the elements in the periodic table are produced when stars die, which they do through a variety of fascinating, complicated and spectacular means. Smaller stars slowly turn themselves inside out, spewing their guts all across their stellar systems. Larger stars explode in violent cataclysms known as supernovas. Both kinds of deaths leave remnants. In the case of small stars, they leave white dwarfs, which are made almost entirely of carbon and oxygen. Larger stars leave behind incredibly dense spheres of neutrons known as neutron stars.
Gas from a companion star can fall onto a white dwarf, causing it to trigger its own kind of supernova blast. Neutron stars can collide with each other, releasing an enormous amount of energy in an event known as a kilonova.
No matter what, all of these processes involve a lot of radiation, a lot of energy and a lot of particles flying around at high speed — in other words, the perfect soup for fashioning new elements. It's through these calamities that the rest of the periodic table came into being.
It's also through these energetic events that these elements spread beyond the bounds of their home stars and out into the interstellar mix. There, those elements join new gas clouds, which eventually coalesce to form new generations of stars that continue the process of elemental recycling and regeneration, slowly enriching the universe.