In this work, the Al x Ga 1-x N-on-sapphire template was successfully prepared by halide vapor phase epitaxy (HVPE) at 1100 o C. The flow ratio (R) of the HCl flow rate through Al metal to the total HCl flow rates through Al and Ga metals was adjusted to control the Al content. The Al x Ga 1-x N films without phase separation can be obtained as the R value exceeds 0.67. The low R value strongly enhances the formation probability of GaN instead of Al x Ga 1-x N. This indicates that a sufficient concentration of the Al precursor is certainly vital for the formation of Al x Ga 1-x N compounds. The Al x Ga 1-x N prepared at the R value of 0.80 can achieve best crystallinity and the lowest surface roughness. Furthermore, the optical transmittance of the Al x Ga 1-x N under R=0.80 is above 70% between the wavelength of 225 nm and 400 nm. As a result, the Al x Ga 1-x N under R=0.80 can be regarded as a suitable growth template for the ultraviolet light-emitting diodes. The internal quantum efficiency of the 370 nm-quantum wells on the Al x Ga 1-x N/sapphire prepared under R=0.80 shows 127% improvement as compared with that on the undoped-GaN/sapphire.