Diffraction gratings are optical elements that are similar to lenses or mirrors.  Diffraction gratings are superimposed with a precise pattern of microscopic periodic structures. Usually these are in a pattern of corrugated surface grooves (a surface-relief grating), though some gratings are formed by the periodic variation of the refractive index inside the grating itself (a volume grating). Gratings used to disperse ultraviolet (UV) and visible light usually contain between 300 and 3000 grooves per millimeter, so the distance between adjacent grooves is on the order of one micron.  Diffraction gratings may be either ruled or holographic, although there is a wider range of groupings within each style.

Ruled diffraction gratings are produced by physically forming grooves into a reflective surface with a diamond mounted on a ruling engine.  Ruled gratings have a relatively sharp peak around their blaze wavelength as a consequence of their "saw tooth" groove profile. The distance between adjacent grooves and the angle the grooves form with respect to the substrate influence both the dispersion and efficiency of a grating.  Diffraction gratings can be ruled on a variety of substrates; for example, glass, metal and ceramic. Groove density ranges from 20 to 1800 grooves/mm. This is the preferred type of grating for the infrared (IR) because of the relatively large spaces between grooves. In this case, there is better control over blaze shape and defects are small relative to the size of the spacing.

Holographic diffraction gratings are formed when a series of interference fringes, corresponding to the grooves of the desired grating, are recorded on a photosensitive layer, and the subsequent chemical treatment forms a modulated profile on the surface of the blank by selective dissolution.  This particular type of diffraction gratings includes many configurations such as planar, curved (for example concave and toroidal), aberration-corrected, with uniform and non-uniform groove spacing. Non-uniform spacing can provide superior focusing characteristics. Holographic gratings are the type of choice for the visible and UV. They typically exhibit less stray light and "ghost" spectra than do classically ruled gratings, because they have fewer random and systematic imperfections.