Rechargeable batteries have become an integrated part of our everyday life as they power most of our electronics and cordless appliances. The technology is now on the verge of breaking through to a larger scale of applications such as electric vehicles and grid-scale energy storage. These applications set new requirements on energy density, price and environmental footprint. The functionality of rechargeable batteries is governed by the materials responsible for the reversible conversion between chemical and electrical energy. The efficiency of this conversion is determined by the atomic structure of the functional materials, that is the identity of the atoms and their relative spatial positions. In this lecture we will take a look at the Li-ion battery technology as we know it today and see examples of how we can use knowledge about atomic structures of the battery electrodes to design and prepare new materials for more efficient and cheaper batteries. We will see how we can utilize X-rays to see the atoms inside the batteries and investigate how they move while the battery is being charged and discharged.