We performed first-principles calculations and O K-edge X-ray absorption near edge structure (XANES) measurements to study the electronic structures of bulk Ba1¡xSrxTiO3 alloys. We found that the energy gaps in these quaternary perovskite alloys are dominantly determined by the Ti-O bonding. A combination of calculations and XANES results shows that a charge transfer effect due to a significant difference in the electronegativity of Ba and Sr plays a significant role in the variation of the electronic structures in these alloys.