Several conditions are needed to produce foam: there must be mechanical work, surface active components (surfactants) that reduce the surface tension, and the formation of foam faster than its breakdown.
To create foam, work (W) is needed to increase the surface area (ΔA):
where γ is the surface tension.
One of the ways foam is created is through dispersion, where a large amount of gas is mixed with a liquid. A more specific method of dispersion involves injecting a gas through a hole in a solid into a liquid. If this process is completed very slowly, then one bubble can be emitted from the orifice at a time as shown in the picture below.
One of the theories for determining the separation time is shown below; however, while this theory produces theoretical data that matches the experimental data, detachment due to capillarity is accepted as a better explanation.
The buoyancy force acts to raise the bubble, which is
where  is the volume of the bubble,  is the acceleration due to gravity, and ρ is the density of the gas ρ is the density of the liquid. The force working against the buoyancy force is the surface tension force, which is
where γ is the surface tension, and  is the radius of the orifice.
As more air is pushed into the bubble, the buoyancy force grows quicker than the surface tension force. Thus, detachment occurs when the buoyancy force is large enough to overcome the surface tension force. 
In addition, if the bubble is treated as a sphere with a radius of  and the volume  is substituted in to the equation above, separation occurs at the moment when
Examining this phenomenon from a capillarity viewpoint for a bubble that is being formed very slowly, it can be assumed that the pressure  inside is constant everywhere. The hydrostatic pressure in the liquid is designated by . The change in pressure across the interface from gas to liquid is equal to the capillary pressure; hence,
where R and R are the radii of curvature and are set as positive. At the stem of the bubble, R and R are the radii of curvature also treated as positive. Here the hydrostatic pressure in the liquid has to take in account z, the distance from the top to the stem of the bubble. The new hydrostatic pressure at the stem of the bubble is p(ρ − ρ)z. The hydrostatic pressure balances the capillary pressure, which is shown below:
Finally, the difference in the top and bottom pressure equal the change in hydrostatic pressure:
At the stem of the bubble, the shape of the bubble is nearly cylindrical; consequently, either R or R is large while the other radius of curvature is small. As the stem of the bubble grows in length, it becomes more unstable as one of the radius grows and the other shrinks. At a certain point, the vertical length of the stem exceeds the circumference of the stem and due to the buoyancy forces the bubble separates and the process repeats.