Potential applications in photonics and optoelectronics are based on our understanding of the light–matter interaction on an atomic monolayer scale. Atomically thin 2D transition metal dichalcogenides, such as MoS2 and WSe2, are model systems for layered semiconductors with a bandgap in the visible region of the optical spectrum. They can be assembled to form heterostructures and combine the unique properties of the constituent monolayers. In this Technical Review, we provide an introduction to optical spectroscopy for layered materials as a powerful, non-invasive tool to access details of the electronic band structure and crystal quality. We discuss the physical origin of the main absorption and emission features in the optical spectra and how they can be tuned. We explain key aspects of practical set-ups for performing experiments in different conditions and the important influence of the direct sample environment, such as substrates and encapsulation layers, on the emission and absorption mechanisms. A survey of optical techniques that probe the coupling between layers and analyse carrier polarization dynamics for spin- and valleytronics is provided. Understanding light–matter interactions in layered materials is crucial for applications in photonics and optoelectronics. This Technical Review discusses the optical spectroscopy techniques to access details of the electronic band structure, crystal quality, crystal orientation and spin–valley polarization, including key aspects of practical set-ups to perform experiments for a broad range of applications.