They contract when they lose their heat. Liquids expand when heated and they contract when cooled. Ice however, expands when it freezes. As the water molecules lose heat, they vibrate less , and are able to form geometric patterns that take up more space . As the volume of ice increases, the density of ice decreases and the ice floats.
Gases expand when heated and contract when cooled.
For instance, a balloon will expand if it is left in a hot car. It will get smaller if it is put in the refrigerator. Many students accept the fact that molecules are moving in liquid water because they can see water flow. However, these students have difficulty believing that the molecules in ice are also moving. Nevertheless, molecules are always moving, even in substances such as ice where no motion of the substance is visible.