Trace elements analysis is a fundamental challenge in environmental sciences. Scientists measure trace elements in environmental media in order to assess the quality and safety of ecosystems and to quantify the burden of anthropogenic pollution. Among the available analytical techniques, X-ray based methods are particularly powerful, as they can quantify trace elements in situ. Chemical extraction is not required, as is the case for many other analytical techniques. In the last few years, the potential for X-ray techniques to be applied in the environmental sciences has dramatically increased due to developments in laboratory instruments and synchrotron radiation facilities with improved sensitivity and spatial resolution. In this report, we summarize the principles of the X-ray based analytical techniques most frequently employed to study trace elements in environmental samples. We report on the most recent developments in laboratory and synchrotron techniques, as well as advances in instrumentation, with a special attention on X-ray sources, detectors, and optics. Lastly, we inform readers on recent applications of X-ray based analysis to different environmental matrices, such as soil, sediments, waters, wastes, living organisms, geological samples, and atmospheric particulate, and we report examples of sample preparation.