In this paper we present a novel technological approach for the fabrication of multilevel gratings in the resonance domain. A coded chromium mask is used to avoid alignment errors in electron beam lithography, which typically occur within the standard multistep binary micro-optics technology. The lateral features of all phase levels of the grating are encoded in a single chromium mask. The final profile of the structure is obtained by selective etching process for each level. This new technological method is applied for the fabrication of two different three-level gratings in resonance domain. The corresponding optical response as well as structural characterizations are presented and discussed. In particular, a first order diffraction efficiency of 90% is demonstrated for a grating period twice the wavelength at normal incidence.