Answer :

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! :)