Solids, liquids and gases expands when heated and contracts when cooled.
Water however shows an anomalous (unusual) behaviour in that it contracts when it is temperature is raised from 0oC to about 4o c. When ice is heated from say -20oC, it expands until its temperature reaches 0oC and it melts with no change in temperature. The melting is accompanied by contraction. The water formed will still contract as its temperature rises from 0oC
Above 4oC, the water expands with increase in temperature. Since volume of a given mass of water is minimum at 4oC, water at this temperature has a maximum density, slightly higher than 1g/cm3.
At the melting point of water (0oC) there is a drastic increase in the volume, resulting in a large decrease in density as the ice forms.