We present a detailed experimental and theoretical analysis of the optical orientation of electron spins in GaAs/AlAs quantum wells. Using time and polarization resolved photoluminescence excitation spectroscopy, the initial degree of electron spin polarization is measured as a function of excitation energy for a sequence of quantum wells with well widths between 63 Ang and 198 Ang. The experimental results are compared with an accurate theory of excitonic absorption taking fully into account electron-hole Coulomb correlations and heavy-hole light-hole coupling. We find in wide quantum wells that the measured initial degree of polarization of the luminescence follows closely the spin polarization of the optically excited electrons calculated as a function of energy. This implies that the orientation of the electron spins is essentially preserved when the electrons relax from the optically excited high-energy states to quasi-thermal equilibrium of their momenta. Due to initial spin relaxation, the measured polarization in narrow quantum wells is reduced by a constant factor that does not depend on the excitation energy.