In order to continue explaining air masses I must first explain density and pressure. Density is a measurement of how close together the air molecules are, or, put another way, a measure of what weight of air exists in any given volume. More weight per volume is the same thing as higher density.
If you pack socks into a box there are two ways to maximize the sock density. One is to use thin, non-fluffy socks and the other is to cram your socks in as hard as you can, stomping on them to get them to fit before you seal the box. (You know I just moved house, right?) These two factors are the same as the ones that affect air density.
'Fluffiness' of the air corresponds of temperature. The higher the temperature, the greater the volume the air wants to occupy. It's actually because the speed of the air molecules is greater at high temperature, but you can think of the volume they thus occupy as them being all fluffed up hot out of the tumble drier. All else being equal, warm air occupies more volume than the same weight of cold air. Therefore, all else being equal, an equivalent volume of cold air weighs more than warm air.
Stomping on the pile of socks corresponds to pressure. Is pressure, really. Pressure is defined as force per unit area, and in the atmosphere it is a result of all the air stacked up on top of the bit of air you're considering. Imagine you're looking at a cubic litre of air(*). Its pressure is equivalent to the weight of all the ten by ten by ten cubes of air that are stacked on top of it, all the way up to the top of the atmosphere. Sure, one little cube of air doesn't weigh much, but stack enough up and it adds up. So air down near the bottom of the atmosphere is at a higher pressure than air further up in the atmosphere, where it has fewer boxes stacked on top of it. Kind of like the box of drinking glasses underneath four boxes of aviation textbooks is under more pressure than the one that is ony one box into a pile.
You can see pressure and temperature kind of work against one another with respect to density. If the pressure increases and the temperture stays the same, the density will increase. If the temperature increases and the pressure stays the same, the density will decrease. Cold air at a high altitude is less dense than warm air at a low altitude, because the effect of the low pressure at high altitude more than balances the effect of the temperature difference. There's even a formula:
P x V = T x constant
P = pressure, T = temperature, V = volume.
So, we have a bunch of air hanging about. Air in the same vicinity within the same air mass is pretty much interchangeable. It's all mostly nitrogen, and contains some amount of moisture, and at the same pressure because its under the same pile of air. And its at the same temperature. If some of it were to be heated up to be warmer than the surrounding air, look at what would happen. Firstly, it doesn't warm the air around it. If air were good at sharing its heat with the molecules around it, down-filled parkas wouldn't be such treasured possessions in the north. (The puffy feathers create little air pockets and heat doesn't travel well through air, so that keeps me warm.) If a little bit of air is warmer than the air around it then it is also less dense than the air around it. And that means that the gravitational force holding it down isn't as great as the pressure differential between the air above it and the air below it, so it is pushed up, and rises.
And yes, I did just spend six paragraphs explaining that hot air rises. Just think of it as a demonstration of hot air. The reason I did it that way is that warm air doesn't always rise. If that were true it would be warmer at the tops of mountains than at the bottom. Air rises if it is less dense than the air around it. If the pressure is the same, then temperature determines density. So it rises if it is warmer than the air around it, sinks if it is colder than the air around it, and stays in the same place if it is the same temperature as the air around it.
There's one further trick to the rising air, as it rises, the pressure around it decreases, so according to the formula, if the temperature stays the same, the volume has to increase. And it does. The rising air expands. It actually also cools as it expands, so the result is that the same air occupies a greater volume at a lower pressure and temperature.
What it does next is for next time this multi-threaded blog returns to weather theory.
(*)If you didn't go to elementary school in Canada after metrification you missed out on carefully measuring ten centimetres by ten centimetres by ten centimetres and building a little cardboard box. That's about four inches cubed, for the aggressively non-metric. Once you'd built and folded your cardboard cube, and mended any measuring or folding errors with vast quantities of cellophane tape, you had a concrete way to visualize a ten centimetre length, one thousand cubic centimetres, one litre capacity, and, if you imagined what your cube would feel like if it were filled with water, one kilogram. I'm not making this up. They used to hand these things out at fairgrounds, in modern 1970s colours like pink, yellow and lime green. Someone back me up here. I'll trade you a working flashlight for a genuine 1970s MetriCube.