We show that the optical and electronic properties of nanocrystalline silicon can be efficiently tuned using impurity doping. In particular, we give evidence, by means of ab initio calculations, that by properly controlling the doping with either one or two atomic species, a significant modification of both the absorption and the emission of light can be achieved. We have considered impurities, either boron or phosphorous (doping) or both (codoping), located at different substitutional sites of silicon nanocrystals with size ranging from 1.1 to 1.8 nm in diameter. We have found that the codoped nanocrystals have the lowest impurity formation energies when the two impurities occupy nearest neighbor sites near the surface. In addition, such s...