From a smooth rainbow to a barcode
In the previous guide you met the inside of an atom: electrons can sit only on certain fixed rungs of energy, and a photon is emitted or absorbed only when an electron jumps between two of those rungs. Because the rungs are fixed, the jump always involves the exact same energy — and so the exact same color of light. Hold on to that one fact; everything in this guide flows from it. We are now going to take that atomic rule and watch what it writes across the rainbow of a distant star.
When you spread light into its colors — with a prism, or the diffraction grating inside a real instrument — you get a spectrum. Sometimes that spectrum is a smooth, unbroken band of color, a clean rainbow with no gaps. But more often it is crossed by thin, sharp features: a single bright color blazing against darkness, or a smooth rainbow interrupted by a missing slice, a dark gap where one color has been stolen away. Each such feature is a [[spectral-line|spectral line]], and a spectrum freckled with them looks less like a rainbow and more like a barcode.
Three kinds of spectrum
Sort the spectra you might see and they fall into exactly three kinds. The first is a [[continuous-spectrum|continuous spectrum]]: an unbroken smear of all colors, with no lines at all. This is the glow of something hot and dense — a solid, a liquid, or a thick gas packed so tightly that its atoms are jostling each other constantly. Their crowded, blurred energy jumps merge into every color at once, so the rainbow comes out smooth. The blackbody glow of a heated iron bar, or the deep interior of a star, makes this kind of light.
The second is an [[emission-line-spectrum|emission-line spectrum]]: mostly darkness, broken by a few bright, sharp lines of pure color and nothing in between. This comes from a thin, hot gas — atoms spread far enough apart that each is free to do its own thing. Heated, its electrons jump up to higher rungs and then fall back down, and each fall releases a photon of one exact color. Since only certain jumps are allowed, only certain colors appear, as isolated bright lines on a black background. A neon sign and a glowing nebula both shine this way.
The third is an [[absorption-line-spectrum|absorption-line spectrum]]: a full, smooth rainbow with thin dark gaps cut into it, as if a few colors had been quietly subtracted. This is what you get when a continuous spectrum passes through a cooler, thin gas on its way to you. The cool atoms catch exactly the photons whose colors match their own allowed jumps, lifting their electrons — so those particular colors are removed from the beam, leaving dark gaps at precisely the wavelengths the gas can absorb. Sunlight does this: the Sun's hot interior makes a continuous rainbow, and its cooler outer atmosphere bites hundreds of dark lines out of it.
Kirchhoff's three laws
In the 1860s, before anyone understood atoms or quantum jumps, Gustav Kirchhoff and Robert Bunsen worked out the pattern by careful experiment and stated it as three simple rules. Today we call them [[kirchhoffs-laws-of-spectroscopy|Kirchhoff's laws of spectroscopy]], and they are nothing more than the three spectra you just met, expressed as a recipe: tell me the source and its arrangement, and I will tell you which kind of spectrum comes out.
- First law — a hot, dense source (a solid, a liquid, or a thick opaque gas) gives a continuous spectrum: an unbroken rainbow with no lines.
- Second law — a hot, thin (low-density) gas gives an emission-line spectrum: bright lines only, at the colors that gas can emit, on a dark background.
- Third law — a continuous source seen through a cooler thin gas gives an absorption-line spectrum: a full rainbow with dark gaps cut at exactly the colors that gas would otherwise emit.
The beautiful part is the symmetry buried in the second and third laws. The same gas of the same element absorbs and emits at exactly the same colors — its dark absorption lines fall at precisely the wavelengths of its bright emission lines. Whether you see bright lines or dark gaps depends only on the geometry: are you looking at the warm gas alone against blackness, or through it at a hotter, brighter source behind? The atom does not change; only your viewing angle does. Heat a gas and look straight at it: emission. Put a brighter background behind it: absorption.
Why the lines are an unforgeable fingerprint
Here is the deep payoff. Every chemical element has its own unique ladder of energy rungs, and no two ladders are alike. So every element produces its own unique set of lines — a fixed pattern of colors that belongs to it and to nothing else. Hydrogen prints a tidy, regular set of lines in the visible band, the Balmer series, its strongest a deep red. Sodium burns a famous pair of close yellow lines, the same yellow you see in an old street lamp. Iron sprinkles thousands of lines across the spectrum. Lay any spectrum beside a catalogue of patterns measured in the laboratory, and you can name the elements present like reading words on a page.
And the same atomic physics holds everywhere, which is what makes this trick reach across the cosmos. A hydrogen atom in a galaxy millions of light-years away has the very same energy rungs as one in a glass tube on a lab bench, so it stamps the very same fingerprint into its light. That is why we can state, with real confidence, what a distant star or gas cloud is made of: not by sampling it, but by recognizing the patterns its atoms cannot help but write. Helium was even found this way — spotted as an unexplained line in the Sun's spectrum in 1868, named for the Greek word for Sun, and only later dug up on Earth.
HOT DENSE source -> continuous (smooth rainbow)
HOT THIN gas -> emission (bright lines on black)
COOL THIN gas in front of
a hot continuous source -> absorption (dark gaps in a rainbow)
same element == same line positions (emission & absorption coincide)Honest limits, and what the lines still carry
Be careful not to over-read the fingerprint. Seeing an element's lines tells you that element is present along the line of sight, but turning the depth or brightness of a line into a precise amount — its chemical abundance — is genuinely hard. How strong a line looks depends not only on how many atoms are there, but on the temperature and density of the gas, which set how many atoms are in the right state to absorb or emit in the first place. The same element can show strong lines in one star and faint lines in another simply because the stars are at different temperatures. Untangling that takes careful physical modeling, not just pattern-matching.
There is also a quiet assumption worth naming: this only works because the same laws of physics hold out there as down here. That is not a logical certainty but a working hypothesis — and one that has survived every test we have thrown at it for over a century, which is why we lean on it with confidence rather than blind faith. Where the assumption is genuinely shakier, near a black hole or in the earliest universe, physicists say so and look for the cracks.