Do x-rays and gamma rays also contain photons like visible light does? Do x-rays and gamma rays also contain photons like visible light does? If so, then what makes photons of visible light and other waves different?
The rest mass of a photon is zero, but as it moves at the speed of light, its mass is infinite. By $E=mc^2$, its energy is infinite, but using formula $ E=h\nu$, we get finite energy. How is this happening? 
 A: Light (all the electromagnetic radiations) is something like raindrops-each little lump of light is called photon-and if the light is all one color, all the "rain-drops" are the same size.$_1$  The size makes photons of visible light and other waves different.  

Credits: $_1$ Richard Feynman-QED, The strange Theory of light and Matter. 
A: Yes, X-ray, UV, and even radio waves are made of photons.
The difference is the Energy (or equivalently, the wavelength).
See the picture of the Electromagnetic spectrum . The different nomination comes from the time of the discovery. Your eyes can see the visible part. the radio waves can be observed with antennas, etc. The only difference is the way we observe it. But they are all the same (photons).
Here is a scale of the different wavelength for electromagnetic waves:

The Energy reads $E=mc^2$ for massive particles, which a photon is not. The good relation is:
$$ E=pc = \hbar c k = h \nu $$
You have to use the complete Einstein relation:
$$ E = \sqrt{p^2c^2 + m^2c^4}$$
And the energy is always finite.
