A diffraction grating is thousands of evenly spaced slits. The rule for where the bright lines go is the same as for the Double-Slit Interference, but with so many slits the bright lines become very sharp and bright, and the space between them goes dark. That makes gratings the heart of spectrometers.
🔑 Key idea
For a grating with $N$ lines per meter, the slit spacing is $d = \dfrac{1}{N}$, and bright lines appear at $$d\sin\theta = m\lambda.$$ Because $\sin\theta \le 1$, the highest order you can see is the largest whole number $m$ with $m\lambda \le d$.
A grating's sharp bright lines. More lines per millimeter means a smaller $d$ and larger angles.
💡 Why it works
At an angle where neighboring slits are a whole wavelength apart, every slit is in step with every other one, so all of them add up: a bright line. Move a little off that angle and the slits get steadily out of step across the grating, and with thousands of them some slit always cancels another. So the bright lines are narrow. Different colors land at different angles, spreading white light into a spectrum.
⚠️ Common mistake
Using the number of lines per millimeter as $d$. A grating marked "$600$ lines/mm" has $d = \frac{1}{600}\ \text{mm} = 1.67 \times 10^{-6}\ \text{m}$, not $600$ of anything. Check: $d$ is a small length, a few times the wavelength; if $\sin\theta$ comes out tiny or huge, you probably forgot the reciprocal.
✏️ Worked example: First-order angle
Green light ($500\ \text{nm}$) falls on a grating with $600$ lines per millimeter. Find the first-order angle.