Using a first-principles band structure method we have systematically studied the electronic properties of Cd-based compounds, alloys and interfaces. We compared the stabilities and band structures of CdX (X=S, Se, Te) in zinc-blende and wurtzite structures. We calculated the mixing enthalpies and optical bowing coefficients of mixed-anion Cd alloys and the band offsets between the Cd compounds. We also calculated the defect formation energies and the defect transition energy levels of point defects and defect complexes in CdTe to search for the best p-type dopant for CdTe.