Density might also vary with pressure, especially for gases.
Within a confined space, mass and volume, and therefore density, remain the same whereas temperature and pressure are mutually effected.
Where volume is not fixed, temperature and pressure have inverse effects on density:
greater temperature = lower density
greater pressure = greater density
Density of various substances are typically referenced to
STP (standard temperature and pressure) conditions.
All gases have the same density as air under STP conditions.
Measuring Density