Although corals look much like plants, they are actually vast colonies of Cnidarian polyps (the same phylum as jellyfish!). These polyps secrete Calcium Carbonate, which forms a protective barrier around them. As old polyps die, new ones grow on top of the remaining exoskeleton, eventually creating the extensive structures that make up coral reefs.
Polyps have tentacles that are extended, usually at night, in order to feed on plankton and small fish. In addition, symbiotic algae called Zooxanthellae live within the coral polyps and provide most of the required nutrients.
(Source: Cornforth Images)