If you scoop up some water from the ocean in a clear glass and look at it closely, you'll see that it's chock full of tiny particles. Seawater contains dissolved salts, proteins, fats, dead algae, and a bunch of other bits and pieces of organic matter. If you shake this glass of ocean water vigorously, small bubbles will form on the surface of the liquid.
Sea foam forms in this way - but on a much grander scale - when the ocean is agitated by wind and waves. Each coastal region has differing conditions governing the formation of sea foams.
Algal blooms are one common source of thick sea foams. When large blooms of algae decay offshore, great amounts of decaying algal matter often wash ashore. Foam forms as this organic matter is churned up by the surf.
Most sea foam is not harmful to humans and is often an indication of a productive ocean ecosystem. But when large harmful algal blooms decay near shore, there are potential for impacts to human health and the environment. Along Gulf coast beaches during blooms of Karenia brevis, for example, popping sea foam bubbles are one way that algal toxins become airborne. The resulting aerosol can irritate the eyes of beach goers and poses a health risk for those with asthma or other respiratory conditions. Scientists studying the cause of a seabird die-offs off California in 2007 and in the Pacific Northwest in 2009 also found a soap-like foam from a decaying Akashiwo sanguinea algae bloom had removed the waterproofing on feathers, making it harder for birds to fly. This led to the onset of fatal hypothermia in many birds.