MgxZn1-xO films were deposited onto the glass substrate by a sol-gel spin coating method. The drying and annealing temperatures were 300 and 500 degrees C in air. As x varies from 0 to 1, it was observed that the crystal structure is changed from wurtzite ZnO to cubic MgO. The morphology characterizations of these films were observed by scanning electron microscope. The randomly oriented hexagonal nanorods were gown on the glass surface when x = 0 and 0.25, which became disappeared with increasing Mg contents. The optical properties of these films were investigated by room-temperature photoluminescence (PL) and UV-vis absorption spectra, which show that the optical band gap and photoluminescence in the visible and UV regions can be ideally tuned by varying the Mg contents in the MgxZn1-xO alloy films. (C) 2009 Elsevier Ltd. All rights reserved.