Solar cells and optical detection devices are often covered with antireflective surfaces to enhance their performance. An economical, fast, and easily operational electrochemical etching technique has been developed to realize a continuous uniform variation in the refractive index of porous silicon layer as a function of the etching depth. By using this technique a black silicon sample was fabricated, which has a reflectance below 5% over a broad band and a thickness below 1μm. The depression mechanism of the optical reflectance is analyzed by simulating the structure with the transfer matrix method. The simulated results give a good agreement with the experimental measurements.