X-rays are simply another form of light, made up of tiny particles called photons that travel in waves. The only difference is that X-rays have much more energy and shorter wavelengths than visible light rays, so they cannot be detected by the human eye.
X-rays have energies that range from hundreds to thousands of times higher than those of visible light rays. This is why X-rays can pass through most materials. It all depends on the size of the atoms that make up the material. Larger atoms absorb X-rays, while smaller atoms do not, and the X-rays pass right through. For instance, the soft tissue in the body is composed of smaller atoms and hence doesn't absorb X-rays very well, whereas the calcium atoms in the bones are much larger and do absorb X-rays.
An X-ray machine shines X-rays onto the body part to be imaged, and a camera on the other side of the patient records the patterns of X-ray light that passes through the patient's body onto a photographic plate or film. This lets doctors see through human tissue to examine broken bones or swallowed objects.
When they were first discovered in 1895, X-rays were believed to be harmless. Radiologists thought nothing of daily exposure to the rays, even though one man lost all his hair after sitting for a radiograph of his skull. Other problems included redness of the skin, numbness, infection, tumors, and severe pain.
Scientists soon realized that X-rays were the cause, and adopted protective measures, such as lead aprons. Why does this happen? When we produce X-rays, we also produce ions, which are electrically charged atoms. An ion's electrical charge can lead to unnatural chemical reactions inside cells. It can break DNA chains, causing the cell to either die or become cancerous. If the mutation occurs in a sperm or egg, the result can be birth defects, which is why pregnant women should never be subjected to X-rays, even in a dentist's office.
X-rays were discovered accidentally by a physicist named William Roentgen. He was studying fluorescent light, and had surrounded his equipment with heavy black cardboard to block visible light. But he noticed that a nearby fluorescent screen glowed anyway. When he placed his hand between the light source and the screen, he saw the silhouette of his bones projected onto the screen. The very first X-ray picture he took was of his wife's hand, with her wedding ring clearly visible.