We present studies of the compositional dependence of the optical properties of AlxGa1-xN(0 <x<0.22) alloys by modulation spectroscopy and photoluminescence. The yellow luminescence, which is well known in GaN and is generally assigned to shallow donor-deep acceptor pair recombination has also been observed in AlxGa1-xN. As aluminum concentration increases, the color of the band changes from yellow (2.2 eV) to blue (2.6 eV). The shift was less than that of the band gap. Together with previously published studies, it implies that the deep acceptor level is pinned to a common reference level to both materials, thus the deep level responsible for the yellow emission is used as a common reference level to determine the hand alignment in AlxGa1-xN/GaN heterojunctions. Combining with the near-band-edge modulation spectra, the estimated ratio of conduction-to-valence band discontinuity is 65:35. Our results are close to the values obtained from PL measurements on Al0.14Ga0.86N/GaN quantum wells and those calculated by linear muffin-tin orbital method and linearized augmented plane wave method.