Layers on top are younger than those below (Principle of Superposition).
After being hardened by hard-water deposits, etc., layers may be stood up or turned over; however, the rocks contain many "up" indicators that tell us which way was right-side up when the sediment was deposited, so we can learn whether it was turned over.
Getting Into "Up" Indicators
Mud cracks, footprints, raindrop imprints go down into mud.
Tops of slightly slanting sand-dune layers are eroded by wind.
Shells on a beach are typically flipped into the stable hollow-side-down position.
Bubbles rise toward the tops of lava flows.
Nothing Succeeds Like Succession
Using these rules, we can put rocks in order from oldest to youngest.
Remarkably, this puts fossils in order, so the more similar in age, the more similar in type—we call this the "Law" of Faunal Succession.