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 ) 10.1063/1.3548872 ; 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 [(1 $\bar 1$ 1 ¯ 00) m-plane or (11 $\bar 2$ 2 ¯ 0) 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.