To gain fundamental understanding of the high-temperature optical gas-sensing and light-energy conversion materials, we comparatively investigate the temperature effects on the band gap and optical properties of rutile and anatase TiO2 experimentally and theoretically. Given that the electronic structures of rutile and anatase are fundamentally different, i.e. direct band gap in rutile and indirect gap in anatase, it is not clear whether these materials exhibit different electronic structure renormalizations with temperature. Using ab initio methods, we show that the electron–phonon interaction is the dominant factor for temperature band gap renormalization compared to the thermal expansion. As a result of different contributions from the acoustic and optical phonons, the band gap is found to widen with temperature up to 300 K, and to narrow at higher temperatures. Our calculations suggest that the band gap is narrowed by about 147 meV and 128 meV at 1000 K for rutile and anatase, respectively. Experimentally, for rutile and anatase TiO2 thin films we conducted UV–Vis transmission measurements at different temperatures, and analyzed band gaps from the Tauc plots. For both TiO2 phases, the band gap is found to decrease for temperature above 300 K quantitatively, agreeing with our theoretical results. The temperature effects on the dielectric functions, the refractive index, the extinction coefficient as well as the optical conductivity are also investigated. Rutile and anatase show generally similar optical properties, but differences exist in the long wavelength regime above 600 nm, where we found that the dielectric function of rutile decreases while that of anatase increases with temperature increase.