Heating: particles of a solid, liquid or gas spread out when heated. The volume goes up but the mass stays the same, so the density goes down. Cooling does the opposite.
That is why hot air rises: it is less dense than the cool air around it. A hot air balloon works this way.
Pressure:
- gases: more pressure pushes particles closer: volume falls, density rises
- liquids: nearly incompressible, only a small effect
- solids: even less affected; the change is usually negligible
Why does ice float? Water is densest at 4 °C. When it freezes at 0 °C its particles arrange in a way that takes more space, so ice is less dense than water and floats. A floating ice layer keeps the water below warm enough for fish in very cold weather.
Inside the Earth: the crust is the lightest layer; density increases towards the centre (upper mantle, lower mantle, outer core, inner core).
Heritage: long before big ships, people crossed rivers on rafts of bamboo (light, hollow, floats easily) and wooden logs.
Tap the diagram to enlarge it
- Heating lowers density
- Pressure matters most for gases
- Ice floats: less dense