From the preceding section, you may realize that the density of the air has a big effect on pressure. In a sense, the air pressure at a given level of the atmosphere is equal to the average density of all the air above that level. The denser the air, the more rapidly pressure increases as you go downward in the atmosphere. Careful, though: this does not mean that dense air implies high pressure. It means that dense air corresponds to a rapid change of pressure with height.
I like to draw an analogy to stacking boxes. Suppose each box is equally filled with (brown) popcorn, so that each box weighs the same. Suppose you stack three boxes. The weight at the bottom of the stack is equal to the total weight of the three boxes, while the weight two-thirds of the way up is equal to the weight of just one box.
Just like weight increases downward, so pressure increases downward. And the amount by which pressure or weight change over a given vertical distance depends directly on the density of the intervening layers.
Now imagine taking four boxes, filling two with popcorn and the other two with sand. Now make two stacks: one with a sand box on top of a popcorn box, and one with a popcorn box on top of a sand box.
Which stack is heavier?