When you're a coral hanging out in the shallows, too much sunlight is a bad thing. Ultraviolet radiation can mess up the algae that live within coral bodies and provide them with much of their sustenance.

That's why many corals fluoresce in sunlight, producing proteins as a kind of sunblock for their little algae buddies. But this made biologists wonder - why do coral species that live deep in the dark sea also fluoresce if they don't have to protect themselves?

Now researchers from the University of Southampton have figured out that deep-sea corals fluoresce for the exact opposite reason to their counterparts from the shallows - but it's still all for the benefit of the algae.

Most corals are symbiotic organisms - these marine invertebrates host microscopic algae of the genus Symbiodinium, commonly known as zooxanthellae. The algae have a safe haven to hang out and eat the coral's waste in the form of carbon dioxide and nitrogen. In return, they photosynthesise more than 90 percent of the coral's nutrients.

It all makes sense when coral reefs are exposed to ample sunlight, but these symbiotic corals have also been found as deep down as 165 metres (540 feet).

Considering that sunlight only reaches down some 200 metres (656 feet) into the ocean, that's a crazy place for a photosynthesising species to call home.

As it turns out, these corals have taken their trick of fluorescing when sun is too bright, and turned it to their advantage, essentially producing their own sunlight in the near-darkness of the deep-sea coral reefs.

The team, led by coral scientist Jörg Wiedenmann, tested several deep-sea coral species in their in-lab aquarium reef, and found that corals glowing in red colours tend to survive better in the long term.

The researchers discovered that when corals fluoresce in red, they convert the deep-water blue light into orange-red light, which the algae can absorb deeper into their cells, thus helping the photosynthetic process.

On top of that, the converted red-shifted wavelengths are scattered in the coral tissue and reflected by the calcium skeleton, even further helping the algae get maximum benefit.

These observations also matched up with what biologists have previously seen in the field - for example, in the Red Sea only the deepest corals radiate an orange-red glow, which makes sense now that we know it's how they amplify the little sunlight that reaches them.

Not only is this a fascinating insight into coral biology, it's also important news when it comes to considering the future of the many endangered coral reefs around the world.

"Deep water habitats are discussed as potential refuges for corals from the increasingly degraded shallow water reefs," says Wiedenmann.

But not all corals have the right tricks up their skeleton to continue fluorescing in darker waters.

"Our work shows that the 'deep blue sea' may not be the welcoming sanctuary our endangered coral reefs can retreat to without consequence," he adds.

"It is of utmost importance we do our best to keep their homes in shallow water habitable."

The research has been published in Proceedings of the Royal Society B.