It all has to do with density (mass per unit of volume). Any material whose density is lower than that of water will float, and any material with a higher density will sink. Wood's density is lower than that of water, so a wooden boat will float on the water.

Ships are typically made of metal, which is denser than water, and therefore air-filled buoyancy chambers are built into them. This makes the ship less dense than the volume of water it occupies, thus enabling it to float. The same principle can be found in submarines; by changing the volume of air/water in the buoyancy chambers, the submarine can either sink or float.


Wikipedia

 

The following video from MIT explains how ships float:

0 comments