Think of it as filling a beaker up with water. Whats down low is more dense. Ever dive in the ocean...what happens to your ears at 8-10 feet? That's the water density.
Actually, that's pressure, not density. Liquids are pretty near incompressible, so their density doesn't change much with pressure.
The water has weight, air does too.
Now that
is correct, and it's why
pressure is higher at the bottom of the fluid mass. But the reason air density changes as you go up through the air mass is that air
is compressible, and so its density changes dramatically with pressure.
Let's start with Boyle's Law:
PV=nRT
...where:
P=pressure
V=volume
n=number of moles
R=universal gas constant
T=temperature
We can reorganize that to:
nR/V = P/T
...and nR/V is proportional to mass per unit volume, or density (
ρ). Thus, air density is proportional to pressure divided by temperature. Note that for these purposes, we use absolute temperature, not the more commonly used Fahrenheit or Celsius scales.
The reason air density goes down as you go up the atmosphere even though (at least up to the tropopause) temperature is also going down (which would otherwise cause density to increase) is that the change in absolute pressure is way greater than the change in absolute temperature. Standard temperature at sea level is 15C, which is an absolute temperature of 288K (degrees Kelvin). As you go up, say, 10,000 feet, that temperature drops about 2 degrees/1000 feet, so temperature at 10,000 MSL drops about 20 degrees to 268K, a reduction of only about 7%. At the same time, pressure drops from 30" Hg to about 20" HG, or a drop of about 33%. Thus, the downward change in pressure overwhelms the reduction in temperature, and air density goes down by about 24%.
Same thing with air. There's more 'sitting on top of it' at lower altitudes so it's more dense.
That's true for air as it is a compressible gas, but not really for water, as it is a liquid and thus virtually incompressible.