How does coral collect energy?

Corals get their food from algae living in their tissues or by capturing and digesting prey. Most reef-building corals have a unique partnership with tiny algae called zooxanthellae. The algae live within the coral polyps, using sunlight to make sugar for energy.

I almost forgot to ask, do algaes that live in their tissues are all safe for them to eat? Or where are poisonous algaes?

Algaes live in the Coral’s tissues. Some can be poisonous. Harmful algaes cloud surface waters, blocking sunlight and preventing the coral’s algae counterpart from growing food for itself and the coral. As the bloom dies and decays, the dissolved oxygen is depleted, causing the coral to suffocate.