In optics, a diffraction grating is a grating with a periodic structure of appropriate scale so as to diffract light, or another type of electromagnetic radiation, into several beams traveling in different directions (i.e., different diffraction angles) known as diffracted orders. The emerging coloration is a form of structural coloration. The directions or diffraction angles of these beams depend on the wave (light) incident angle to the diffraction grating, the spacing or periodic distance between adjacent diffracting elements (e.g., parallel slits for a transmission grating) on the grating, and the wavelength of the incident light. Because the grating acts as a dispersive element, diffraction gratings are commonly used in monochromators and spectrometers, but other applications are also possible such as optical encoders for high-precision motion control and wavefront measurement.
For typical applications, a reflective grating has ridges or "rulings" on its surface while a transmissive grating has transmissive or hollow slits on its surface. Such a grating modulates the amplitude of an incident wave to create a diffraction pattern. Some gratings modulate the phases of incident waves rather than the amplitude, and these types of gratings can be produced frequently by using holography.