At high altitudes the pressure is low, so the air decompresses (expands), which, according to the laws of thermodynamics, leads to a decrease in temperature.
The Sun's energy, which is mostly shorter-wavelength visible light photons (since it is approximately a 5800 K blackbody), is absorbed by the ground, and then re-radiated as longer-wavelength IR photons (since the ground is approximately a ~300 K blackbody).
The molecules and aerosol particles in the atmosphere are mainly heated by these lower-energy IR photons; very little by direct absorption of the Sun's energy, because the energy transitions are too large.
The extra proximity of the mountain top to the Sun is absolutely negligible, when compared to the Sun-Earth distance.
Thus, the atmosphere is basically heated from below, rather than from above.
Then, the expansion/pressure effect described by Michal Michalowski acting on this system makes it cooler at higher altitudes.
*For a detailed discussion see the last part of "The Structure of Planetary Atmospheres" at http://cseligman.com/text/planets/atmospherestructure.htm )*
(Simplified summary)
Heat naturally flows from areas near the surface of a planet (even for planets without a surface, from the region where most of the heat of the Sun is absorbed) toward the upper atmosphere. If for some reason the temperature gradient (the change of temperature as you move upward) is less than a certain value (the "adiabatic gradient"), so that the temperature at higher altitudes is too close to that of the surface, strong vertical mixing (convection) occurs, increasing the change in temperature (and decreasing the temperature at higher altitudes) as you go upward. On the Earth, that results in an average decrease in temperature of about 16 Fahrenheit degrees per mile of altitude. On planets with stronger gravity, the temperature decreases more rapidly, while on planets with weaker gravity, the temperature decreases less rapidly (the rate of temperature change is defined by a "scale height").
It is true that in the far upper atmosphere, absorption of high-energy UV radiation by the atmosphere increases the temperature by as much as a thousand or more degrees; but that only occurs at altitudes so far above the surface that for all practical purposes you are "in space", and not "in the atmosphere".
*There are also diagrams and other information available at "The Structure of the Earth's Atmosphere" at http://cseligman.com/text/planets/atmosstructure.htm and "The Surfaces of the Outer Planets" at http://cseligman.com/text/planets/outersurfaces.htm *
As air rises, the pressure decreases. It is this lower pressure at higher altitudes that causes the temperature to be colder on top of a mountain than at sea level. This hot air can indeed rise. But as it does, the atmospheric pressure decreases, the air expands, and it cools. So, even though they're closer to the sun, thin air in the mountains keeps them colder than the thicker air in the lowlands surrounding them. The basic answer is that the farther away you get from the earth, the thinner the atmosphere gets. The total heat content of a system is directly related to the amount of matter present, so it is cooler at higher elevations. The heating of the earth itself also plays a role. During the winter, the sun's rays hit the Earth at a shallow angle. These rays are more spread out, which minimizes the amount of energy that hits any given spot. Also, the long nights and short days prevent the Earth from warming up. NASA Earth Fact Sheet with precise perihelion and aphelion distances. So, Earth is closest to the sun every year in early January, when it's winter for the Northern Hemisphere and we're farthest away from the sun in early July, during our Northern Hemisphere summer.Both the Arctic (North Pole) and the Antarctic (South Pole) are very cold because they get very little direct sunlight. The Sun is always low on the horizon, even in the middle of summer. In winter, the Sun is so far below the horizon that it doesn't come up at all for months at a time. Fluid density (𝜌), pressure (𝑝), depth (ℎ), and the surrounding acceleration due to gravity (𝑔) are related through the equation 𝑝 = 𝜌 𝑔 ℎ. A body of density p is dropped from rest from a height h into a lake of density q where q˃p. Pressure = height of the column × density of the liquid × gravitational field strength p = h ρ g (In any calculation the value of the gravitational field strength (g) will be given.) The two have an inverse relationship, that is, when elevation increases, atmospheric pressure decreases. This is due to the amount of air on top of you at your current elevation. At lower elevations, you have more air above you, and thus more pressure.
The top of a mountain is cold even though it is closer to the sun because of the relationship between pressure, density, and height.
Pressure: The weight of the air above us is called air pressure. The air pressure is highest at sea level and decreases as we go up in altitude. This is because there is less air above us at higher altitudes.
Density: The density of air is the amount of air in a given volume. The density of air decreases as we go up in altitude. This is because there are fewer air molecules per unit volume at higher altitudes.
Temperature: The temperature of air is the average kinetic energy of the air molecules. The temperature of air decreases as we go up in altitude. This is because the air molecules spread out more at higher altitudes, which causes them to move more slowly and have less kinetic energy.
The relationship between pressure, density, and temperature is known as the ideal gas law. The ideal gas law states that the pressure of a gas is proportional to its density and temperature.
So, as we go up in altitude, the pressure decreases, the density decreases, and the temperature decreases. This is why the top of a mountain is cold even though it is closer to the sun.
In addition to the effects of pressure and density, the top of a mountain can also be cold because of the lack of clouds. Clouds trap heat, so the top of a mountain that is clear of clouds will be colder than a mountain that is covered in clouds.
Finally, the top of a mountain can also be cold because of the wind. The wind can remove heat from the top of a mountain, making it even colder.
So, the next time you're wondering why it's so cold at the top of a mountain, remember the relationship between pressure, density, temperature, and clouds.
The ideal gas law states that the pressure of a gas is proportional to its density and temperature. So, as we go up in altitude, the pressure decreases, the density decreases, and the temperature decreases. This is why the top of a mountain is cold even though it is closer to the sun. This hot air can indeed rise. But as it does, the atmospheric pressure decreases, the air expands, and it cools. So, even though they're closer to the sun, thin air in the mountains keeps them colder than the thicker air in the lowlands surrounding them. With increasing altitude or altitude, the temperature decreases. The height of the mountains is much higher than that of the plains, and their temperature is lower than that of the plains. The atmosphere is warmed by radiation from below the earth. Therefore, the lower floors are warmer than the upper floors.During July (at aphelion), the northern half of our planet tilts toward the sun, heating up the land, which warms up easier than the oceans. During January, it's harder for the sun to heat the oceans, resulting in cooler average global temperatures, even though the Earth is closer to the sun. During the winter, the sun's rays hit the Earth at a shallow angle. These rays are more spread out, which minimizes the amount of energy that hits any given spot. Also, the long nights and short days prevent the Earth from warming up. The temperature gets colder the higher up the mountain you go. This is because as the altitude increases, the air becomes thinner and is less able to absorb and retain heat. The cooler the temperature the less evaporation there is, so there is more moisture in the air too. In the free atmosphere, the air's density decreases as the air is heated. Pressure has the opposite effect on air density. Increasing the pressure increases the density. Pressure = height of the column × density of the liquid × gravitational field strength p = h ρ g (In any calculation the value of the gravitational field strength (g) will be given.) p=p0+ρhg, Where p is the pressure at a particular depth, p0 is the pressure of the atmosphere, ρ is the density of the fluid, g is the acceleration due to gravity, and h is the depth. The pressure exerted by a liquid depends on the height of the liquid column. Pressure can be written as P = ρ g h where h is height and ρ is density. The formula shows the direct relation between the pressure and height of the column. Therefore, as the height increases, pressure will also increase. So the height is inversely proportional to the density of the fluid ρ. In this case, since pressure is constant, height is inversely proportional to density of the liquid.