Abstract This paper presents experimental and theoretical studies of binary semiconductor CdS, Zn:CdS, and (Zn-Ni) co-doped CdS. Thin films of pure CdS, Cd35ZnS36, and Cd34ZnNiS36 alloys grown by sol-gel spin coating were analyzed using X-ray diffraction, EDX, and UV-vis spectroscopy. The experimental results show the success of growing nanomaterials in hexagonal structures with crystallite sizes ranging from 1.6 to 2.11 nm and possessing band gaps in the region 2.30 -2.49 eV. Additionally, we investigate the structural and optoelectronic properties of these materials in the ground state using the density functional theory implemented in the WIEN2k software. The first principles calculations confirmed that the structural and optical properties of CdS align with the experimental results. For nanostructure Cd35ZnS36, the lattice parameters decrease, and the band gap increases to 2.85 eV with Zn doping. The (Zn-Ni) co-doped CdS structure optimization shows that the ferromagnetic configuration is more stable than the non-magnetic structure. The spin-polarized band structure investigations reveal that the majority spin-up channel is about 2.79 eV while the minority spin-down channel is around 2.19 eV. These results increase the importance of Zn:CdS and CdZnNiS alloys for optoelectronic and spintronic applications. The calculated optical properties of CdS, Zn:CdS, and (Zn-Ni) co-doped CdS show slight changes in refractive index and extinction coefficient with the doping and a quantitative agreement with the experimental findings.