Subwavelength metallic and dielectric diffraction gratings which rotate the linear polarization of incident light by 90 degrees are examined. Using rigorous diffraction theory in total-internal-reflection configuration, it is shown that full conversion from incident transverse electric field to transverse magnetic zero-order field can be achieved with both dielectric and metallic elements, but dielectric gratings provide higher efficiency and are thus preferable. The fabrication aspects and constraints are discussed in detail and the behavior of the gratings over broad wavelength bands is presented.