As the density of the gases in this layer decrease with height, the air becomes thinner. Therefore, the temperature in the troposphere also decreases with height in response. As altitude increases, the amount of gas molecules in the air decreases the air becomes less dense than air nearer to sea level. This is what meteorologists and mountaineers mean by "thin air." Thin air exerts less pressure than air at a lower altitude.The temperature increases in the stratosphere due to the ozone layer being there that captures radiation. The temperature decreases in the next layer, the mesosphere, because there is no ozone layer there for protection the amount of air in this layer decreases.
The troposphere and the stratosphere are the two lowest layers of the atmosphere. The troposphere is the layer next to Earth's surface. On the average, it extends 11 km to the top of the troposphere which is called the tropopause. In the troposphere, the temperature generally decreases with altitude. Temperature increases as you gain altitude in the stratosphere and the thermosphere. Temperature decreases as you gain altitude in the troposphere and mesosphere. Air temperature varies in complicated ways with altitude. As the density of the gases in this layer decrease with height, the air becomes thinner. Therefore, the temperature in the troposphere also decreases with height in response. The decrease in temperature with height is due to the decrease in solar heating from the stratosphere. Just below the mesopause the temperature is the coldest on Earth. The higher gravity causes the temperature to rise. Notice that in the troposphere warmer air is beneath cooler air. High-altitude locations are usually much colder than areas closer to sea level. This is due to the low air pressure. Air expands as it rises, and the fewer gas molecules including nitrogen, oxygen, and carbon dioxide have fewer chances to bump into each other. A temperature inversion is a layer in the atmosphere in which air temperature increases with height. An inversion is present in the lower part of a cap. The cap is a layer of relatively warm air aloft. The thermal inversion in the stratosphere on Earth is due to absorption of ultraviolet radiation by Ozone (O3) but can be generated by other molecules on different planets. Above the stratosphere the temperature decreases with height due to cooling in the infrared, mainly by CO2. Layer of the atmosphere closest to the Earth's surface, while the stratosphere is the layer of the atmosphere farthest from the Earth's surface the major cause of temperature inversions in the atmosphere is the Earth's atmospheric circulation.