
To keep the submarine level at any set depth, the submarine maintains a balance of air and water in the trim tanks so that its overall density is equal to the surrounding water ( neutral buoyancy). The hydroplanes are angled so that water moves over the stern, which forces the stern upward therefore, the submarine is angled downward. In addition, the submarine has movable sets of short "wings" called hydroplanes on the stern (back) that help to control the angle of the dive.

A supply of compressed air is maintained aboard the submarine in air flasks for life support and for use with the ballast tanks. As the submarine dives, the ballast tanks are flooded with water and the air in the ballast tanks is vented from the submarine until its overall density is greater than the surrounding water and the submarine begins to sink ( negative buoyancy). When the submarine is on the surface, the ballast tanks are filled with air and the submarine's overall density is less than that of the surrounding water. To control its buoyancy, the submarine has ballast tanks and auxiliary, or trim tanks, that can be alternately filled with water or air (see animation below). Unlike a ship, a submarine can control its buoyancy, thus allowing it to sink and surface at will. This displacement of water creates an upward force called the buoyant force and acts opposite to gravity, which would pull the ship down.

A submarine or a ship can float because the weight of water that it displaces is equal to the weight of the ship.
