The structural, electronic and optical properties of perfect MgxZn1-xAl2O4 oxides have been studied by first-principles calculations within the generalized gradient approximation of the density functional theory. It is interesting to note that a linear increase of cell volume (V) with increasing doping amount (x) occurs. The band gap increases in the series from 3.851 eV to 5.079 eV, which is in agreement with theoretical and experimental values. In addition, a blue shift of the absorption shoulder is observed in the UV region with the increase of x, as predicted by the imaginary part e2(w) of the dielectric function at zero frequency as well as bandgap. This can be explained by the threshold of the electronic transition from O-2p to the empty Mg-3p electron states due to the substitution of Zn with Mg. The real part e1(w) of the dielectric function located at zero frequency has a square fit relationship with refractive index n(0), which is 1.71-1.77 from x=0 to x=1. The energy-loss function shows that the replacement of Zn by Mg is responsible for a decrease in the intensity of the sharp peaks. The reflectivity shows that a higher coefficient of reflectivity (R(0)) at zero frequency corresponds to a smaller bandgap. Keywords: electronic transitions, dielectric function, refractive index, adsorption shoulder Preiskovali smo strukturne, elektronske in opti~ne lastnosti idealnih MgxZn1-xAl2O4 oksidov, izpeljane iz teoreti~nih osnov znotraj posplo{ene gradientne aproksimacije funkcionalne teorije gostote. Opazili smo linearno pove~anje celi~nega volumna (V) z nara{~ajo~o koncentracijo Mg (x). [irina prepovedanega pasu nara{~a od 3.851 eV to 5.079 eV v skladu s teoreti~nimi in eksperimentalnimi vrednostmi. Poleg tega ob nara{~anju dele`a Mg opazimo modri premik dodatnega absorpcijskega vrha v UV obmo~ju, kakor napovedujeta vrednosti imaginarnega dela e2(w) dielektri~ne funkcije pri frekvenci 0 in prepovedanega pasu. To je mogo~e pojasniti s pragom elektronskega prehoda elektronov iz O-2p v prazen Mg-3p zaradi nadomestitve Zn z Mg. Kvadrat realnega dela e1(w) dielektri~ne funkcije pri frekvenci 0 se ujema z lomnim koli~nikom n(0), ki je 1.71-1.77 za x=0 do x=1. Funkcija izgube energije, ka`e, da zamenjava Zn z Mg povzro~a zmanj{anje intenzitete ostrih vrhov. Reflektivnost ka`e, da vi{ji koeficient refleksije (R(0)) pri frekvenci 0 odgovarja manj{i {irini prepovedanega pasu. Klju~ne besede: prehodi elektronov, dielektri~na funkcija, lomni koli~nik, dodatni absorpcijski vrh