Question: An excerpt from [this](http://www.chem4kids.com/files/matter_gas.html) page:

> 
> Gases can fill a container of any size or shape. It doesn't even matter how big the container is. The molecules still spread out to fill the whole space equally. That is one of their physical characteristics. 
> 
> 
> 

If a fixed quantity of gas is let out in a limited space, will it spread out equally and maintain a fixed gas distribution throughout the space?

Or, does it go where the gravitational pull is maximum? And what factors affect the distribution of gas in a given area?

Answer: 
Yes, without gravity, the gas fill out the space evenly so you can get uniform distribution of gas. Certainly, it only occurs at thermodynamic equilibrium, that is, if you wait for a long time.

With gravity, the density would be higher at location of lower gravitational potential. If we can treat the gas as ideal gas, then each gas molecule is independent with each other and the distribution will be following the Boltzmann distribution $e^{-E/k\_BT}$.

Near the surface of the Earth, the energy is roughly given by $E=mgh$, therefore the higher from the ground, the lower the density and it decreases exponentially. Real situation are more complicated as the molecule can absorb light energy, but it is still true in general. So the Earth can trap the gas even though it is not a closed container.

In practice, gas in small container can be treated as uniformly distributed since the gravitational potential difference is small.
Well we know from experience that gas will eventually cluster together and form gravitational wells. Just looking at the sky shows proof of this (in the form of stars)\*.

Yet that site is still a common description of gasses. How can this be? The difference stems from the model used.  

The site talks about statistical/classical thermodynamics: It describes an ideal gas; a gas that to consist of hard particles which do not influence each other in any shape. So in this model there simply can't be any "gravitational" effect. Gravity is an effect where the molecules do react on each other, and as such the substance can no longer be described using the equations for an ideal gas

Now to describe this (and other) effects there are a lot of other models. However you should understand that for a lot of applications the classical thermodynamic laws are still valid (within error bounds).

\*The exact effect of formation of stars is something non trivial though, simple Newtonian mechanics/gravity is too limited to describe this. This is an active field of study.