Band gaps and band alignments for AlN, GaN, InN, and InGaN alloys are investigated using density functional theory with the with the Heyd-Scuseria-Ernzerhof {HSE06 [J. Heyd, G. E. Scuseria, and M. Ernzerhof, J. Chem. Phys. 134, 8207 (2003); 124, 219906 (2006)]} XC functional. The band gap of InGaN alloys as a function of In content is calculated and a strong bowing at low In content is found, described by bowing parameters 2.29 eV at 6.25% and 1.79 eV at 12.5%, indicating the band gap cannot be described by a single composition-independent bowing parameter. Valence-band maxima (VBM) and conduction-band minima (CBM) are aligned by combining bulk calculations with surface calculations for nonpolar surfaces. The influence of surface termination [(1100) mplane or (1120) a-plane] is thoroughly investigated. We find that for the relaxed surfaces of the binary nitrides the difference in electron affinities between m-and a-plane is less than 0.1 eV. The absolute electron affinities are found to strongly depend on the choice of XC functional. However, we find that relative alignments are less sensitive to the choice of XC functional. In particular, we find that relative alignments may be calculated based on Perdew-Becke-Ernzerhof [J. P. Perdew, K. Burke, and M. Ernzerhof, Phys. Rev. Lett. 134, 3865 (1996)] surface calculations with the HSE06 lattice parameters. For InGaN we find that the VBM is a linear function of In content and that the majority of the band-gap bowing is located in the CBM. Based on the calculated electron affinities we predict that InGaN will be suited for water splitting up to 50% In content.