A cadaver in the water starts to sink as soon as the air in its lungs is replaced with water. Once submerged, the body stays underwater until the bacteria in the gut and chest cavity produce enough gas -- methane, hydrogen sulfide, and carbon dioxide -- to float it to the surface like a balloon. (The buildup of methane, hydrogen sulfide, and other gases can take days or weeks, depending on a number of factors.) At first, not all parts of the body inflate the same amount: The torso, which contains the most bacteria, bloats more than the head and limbs. The most buoyant body parts rise first, leaving the head and limbs to drag behind the chest and abdomen. Since arms, legs, and the head can only drape forward from the body, corpses tend to rotate such that the torso floats facedown, with arms and
legs hanging beneath it.
Therefore a body floats because of gas build up.