X-rays are a type of radiation that can pass through the body. They can't be seen by the naked eye and you can't feel them.
As they pass through the body, the energy from X-rays is absorbed at different rates by different parts of the body. A detector on the other side of the body picks up the X-rays after they've passed through and turns them into an image.
Dense parts of your body that X-rays find it more difficult to pass through, such as bone, show up as clear white areas on the image. Softer parts that X-rays can pass through more easily, such as your heart and lungs, show up as darker areas.