Sometimes, minerals entirely replace the original skeletal material, quite literally petrifying or “turning it to stone”. In other cases, the bone dissolves away after the encasing sediment has lithified -- turned to rock leaving a bone-shaped hollow called a mould.
Successful fossilisation usually depends on the creature being interred in a mineral rich medium that seals out air and water, preventing parts from decay. This is the reason that only certain types of rock contain fossils; for example, sedimentary sandstone, shale, and mudstone from swamps and lakes.
However, in some very rare instances, desert (dune) sand has also been known to contain fossils.
Soft tissues usually decay before fossilisation can take place; however, skin imprints can sometimes be fossilised when the sediment that covers the dinosaur hardens while retaining its pattern. Tracks of dinosaur footprints also become preserved in rock this way.
These imprints allow us to see whether they walked on two or four feet, whether the tail was dragging on ground or rose, and whether they were running or walking - from the imprint of the individual toes, and from how big the strides were.