Why are coral reefs generally limited in distribution to shallow marine waters?

You will find the answer here.

http://www.pennekamppark.com/reefinfo.html

They acquire energy from the sun, through photosynthesis carried out by plankton withing the polyps. They also prefer the warmer water of shallow seas.