We report a theoretical study of the electronic structure and optical properties of the B phase of niobium pentoxide (B-Nb2O5) and tantalum pentoxide (B-Ta2O5) by means of first-principle calculations. We have used density functional theory along with the revised Perdew–Burke–Ernzerhof (PBEsol) exchange-correlation functional and the Heyd–Scuseria–Ernzerhof (HSE06) hybrid functional. It has been found that these compounds are indirect wide-gap semiconductors, the calculated gaps for B-Nb2O5 (B-Ta2O5) are and eV. We have also calculated the frequency-dependent and static dielectric tensor, the refraction index and the transmittance. The calculated average static dielectric constants of B-Nb2O5 (B-Ta2O5) are 33.7 (30.9), in good agreement with the available experimental data.