Using x-ray absorption spectroscopy recent progress is achieved all over in solid state physics. This review focuses on these advances, with particular emphasis on applications to surface physics and to magnetism of ultrathin 3d and 5d films that are made possible by the use of undulators in third generation synchrotron radiation sources: the unambiguous appearance of an atomic extended x-ray absorption fine structure for atomic adsorbates and of σ* resonances in near-edge x-ray absorption fine structure spectra of oriented molecules is demonstrated. The induced magnetism at the interfaces of 3d and 5d layers is studied by x-ray magnetic circular dichroism. Fundamental aspects of the spectroscopy are clarified for rare earth crystals. The determination of the ground state properties and the detailed understanding of the underlying mechanisms was obtained by comparison of the experimental data to state-of-the-art ab initio calculations.