How does elevation affect temperature?

The higher you go, the colder it gets. For example, it is colder in the mountains than on a plain or by the ocean