CdS-ZnO nanocomposite thin films were prepared using the sol-gel technique. Highly confined nanoparticles of CdS (radius 1.8-4.7 nm) were obtained with ZnO as the matrix. The molar ratio of CdS and ZnO was varied within the range 20 : 80 to 60 : 40. The influence of the annealing temperature (373-573 K) on the particle size was studied from the blue shift (0.1-0.7 eV) of the absorption edge and transmission electron microscopy. The microstructural characterization by high resolution transmission electron microscopy indicated well-resolved crystalline nanoparticles. Photoluminescence studies indicated three surface related peaks at 2.33, 2.19 and 1.89 eV for all the CdS-ZnO nanocomposites. The optical band gap (Eg) determined without preassuming the nature of the optical transition varied in the range 2.52-3.16 eV with variation of the annealing temperature, showing excellent carrier confinement of the CdS nanoparticles within the wide band gap ZnO matrix. This study indicated ZnO to be a good capping material for CdS nanoparticles.