Density is a measure of how much mass a material has in a specific volume of space. Therefore the more atoms per unit volume a material has and the more mass those atoms have, the higher the density will be. When you heat something up, it takes up more space and therefore becomes less dense. Most materials will be at their densest when they are a solid, ie when their atoms are closest together. Water does not follow this rule as we all know that ice floats on water therefore ice is less dense than water! So when is water at its densest? Well, it turns out this happens to be around 44°C.
This is when the water molecules are closest together. Cooling water further than 4°C causes the density to decrease up to the point where it becomes a solid which is less dense than the liquid. This happens due to the unusual way that the water molecules arrange themselves when turning into a solid, it is known as a crystalline structure and it is such an arrangement that the molecules are further apart from each other as a solid than when they were a liquid.
Plus, take a look at: