If you take a fluid (i.e. air or water) and heat it, the portion that is heated usually expands. The same mass takes up more volume and as a consequence the heated portion becomes less dense than the portion that is not heated.
Cooling a substance causes molecules to slow down and get slightly closer together, occupying a smaller volume that results in an increase in density. Hot water is less dense and will float on room-temperature water. Cold water is more dense and willsink in room-temperature water.