Atmospheric pressure is caused by the gravitational attraction of the planet on the atmospheric gases above the surface and is a function of the mass of the atmosphere above the location and the altitude. It is also related to air density, which in turn is influenced by temperature. Warm air is less dense than cooler air, so changes in air temperature can lead to changes in air pressure. As a result, pressure increases with warmer temperatures in a closed container, but in the atmosphere, heated air expands and becomes less dense, leading to a decrease in pressure. Additionally, pressure decreases with height, as there is less overlying atmospheric mass at higher elevations, resulting in lower atmospheric pressure