As liquid or gas is heated, it expands. There is the same amount of matter, but in a larger space. Therefore, the density will decrease as liquid or gas is heated.
The opposite is also true. As a liquid or gas gets cooler, its density increases as the matter occupies a smaller space.
Hope this helps! :)
Heating a liquid or gas increases the kinetic energy of its molecules, causing them to spread apart and expand. This expansion leads to an increase in volume while the mass remains constant, resulting in a decrease in density. Conversely, cooling a substance will decrease its volume and increase its density.
;