Enhanced light absorption of solar cells and photodetectors by diffraction is described. Triangular, rectangular, and blazed subwavelength periodic structures are shown to improve performance of solar cells. Surface reflection can be tailored for either broadband, or narrow-band spectral absorption. Enhanced absorption is achieved by efficient optical coupling into obliquely propagating transmitted diffraction orders. Subwavelength one-dimensional structures are designed for polarization-dependent, wavelength-selective absorption in solar cells and photodetectors, while two-dimensional structures are designed for polarization-independent, wavelength-selective absorption therein. Suitable one and two-dimensional subwavelength periodic structures can also be designed for broadband spectral absorption in solar cells and photodetectors. If reactive ion etching (RIE) processes are used to form the grating, RIE-induced surface damage in subwavelength structures can be repaired by forming junctions using ion implantation methods. RIE-induced surface damage can also be removed by post RIE wet-chemical etching treatments.