It has been written that the oceans on this little planet we call earth are a "giant bowl of soup". If you take a look at what is actually in the oceans, from the microscopic bacteria to the minute animals in plankton, to the fish that you put in your marine aquarium, to the largest forms of life (whales), all of which end up as food for something at some point in time. And don't forget the critters that crawl, slither and/or walk on the bottom of the ocean. Everything eats something and in the end, is eaten by something. Even humans, when we jump (or fall) into the ocean, enter the food chain. Kind of spooky when you think about it.
The critters in the ocean generally fall into one of three categories: Herbivores (plant eating), carnivores (meat eating) or omnivores (consume both meat and plants). The differences between a herbivore's and a carnivore's digestive system are quite remarkable.
A herbivore's digestive tract is quite a bit longer than a carnivore's for one simple reason: It takes more time for a herbivore to break down vegetable matter fiber that contains cellulose. The herbivore's digestive tract contains a huge amount (billions) of symbiotic bacteria, which actually break down the cellulose fiber which actually contains no proteins, which the animal needs to survive. The herbivore's digestive tract ends up digesting the bacteria, which do contain protein. The herbivore's system can digest starches, which the fish needs for energy.
A carnivore's digestive tract is much shorter than herbivores and produces digestive enzymes (acids) which break down meat so it can be absorbed and utilized.
Every species in the ocean has its "preferred" food, but most (not all) will settle for something else when faced with starvation. Ideally, the fish and other critters in your saltwater aquarium should be fed their "preferred" food in some form for several reasons. The first and foremost reason is that they will normally eat it. The second reason is that the food they have been eating in nature provides all of their nutritional needs to survive and thrive.
Herbivores in the oceans consume plant life such as macroalgae, microalgae and true flowering marine plants that are not algae at all but are sea grasses such as turtle, eel, and a few others. Many herbivores, such as the Surgeonfish, primarily dine on algae but are not averse to eating something with a meat base when given the opportunity. Good examples of this are the Yellow Tang and Naso Tang which will consume certain Red Algae and Green Algae by the bucketful but will gobble up mysid shrimp when given the chance.
In a saltwater aquarium, many fish (even carnivores) can be weaned off of their usual fare in the wild and coaxed into taking hand fed foods such as pellets and flakes with their protein requirements being supplemented with frozen foods such as mysid shrimp, fish, squid or krill.
The 11 Primary Food Groups of Marine Fishes Table shows the different foods and which fish eat them in more detail.