Soft phonon modes in strongly anharmonic crystals are often neglected in calculations of phonon-related properties. Herein, we experimentally measure the temperature effects on the band gap of cubic SrTiO3, and compare with first-principles calculations by accounting for electron-phonon coupling using harmonic and anharmonic phonon modes. The harmonic phonon modes show an increase in the band gap with temperature using either Allen-Heine-Cardona theory or finite-displacement approach, and with semilocal or hybrid exchange-correlation functionals. This finding is in contrast with experimental results that show a decrease in the band gap with temperature. We show that the disagreement can be rectified by using anharmonic phonon modes that modify the contributions not only from the significantly corrected soft modes, but also from the modes that show little correction in frequencies. Our results confirm the importance of soft-phonon modes that are often neglected in the computation of phonon-related properties and particularly in electron-phonon coupling.