Different parts of the body absorb the x-rays in varying degrees. Dense bone absorbs much of the radiation while soft tissue, such as muscle, fat and organs, allow more of the x-rays to pass through them. As a result, bones appear white on the x-ray, soft tissue shows up in shades of gray and air appears black.
It is due to absorption