A new method for designing holographic optical elements is presented. The method is based on matching the grating-spacing profile of the recording light interference pattern to the desired grating-spacing profile. We show that for designing near-field holograms, in which the optical images involved are close to the hologram aperture, the grating-matching technique is superior to the well-established aberration-balancing method introduced by Latta [Appl. Opt. 10, 609 (1971)].