Sedimentary rocks are formed in what geologists term depositional environments. Most depositional environments involve transport and laying down of material (rocks, dirt, minerals, volcanic ash, and biological matter such as leaves or animals) by the action of either wind or water. This deposited material is called sediment, and the process of laying down the sediments is called sedimentation. The sediments accumulate in layers whose composition is determined by the source of the deposited material. Over time, thick layers of sediment accumulate and turn into sedimantary rocks such as sandstone, mudstone, and limestone.
Fossils are preserved during the formation of sedimentary rocks. In general, the process of fossilization involves burial of an animal by water or wind borne material. The soft tissues decay, leaving the hard bone which is eventually either replaced, or added to, by local minerals.
Although the variations between the layers of sediments can be very subtle, a geologist who is familiar with the area can easily distinguish them and tell the story of a time 30 - 40 million years ago.