That’s a good question, reader Jay. Marshmallow is one of the simpler foams, but still an interesting object to contemplate. It’s primarily a sugar syrup with lots of air whipped into it, though it wouldn’t hold up for terribly long if it didn’t have some sort of support. That support is usually gelatin.
I’ve discussed gelatin exhaustively in the past. The shorthand is that it’s made of long-chain protein molecules which in their natural state are chemically bondered together and coiled around each other like rope. When heated in liquid, geltain proteins release their bonds, uncoil and disperse. As they cool they start to bond to one another again. However having uncoiled they can’t go back to their original, tight configuation. The result is a loose network of interconnected molecules that prevents other molecules around them from flowing. A semi-solid material results.
So imagine if you will a thick sugar syrup in a mixer. As the whip goes around thousands upon thousands of tiny bubbles are introduced. The mixture becomes thicker, but not thick enough. That’s where those gelatin proteins come in. They surround the little bubbles, reinforcing them and preventing them from popping. As the marshmallow cools the gelatin proteins bond to each other, effectively freezing the whole matrix in place.
Oh, and to answer your question, reader Mari, the reason the semi-clear liquid turns into a bright white material is because of all those teeny tiny bubbles. They prevent light rays from passing through the mixture, and bounce them right back to our eyes.