Phytoliths are microscopic particles of silica that form in plant tissues. They form when plants uptake hydrous silica from soils through the roots. Hydrous silica can then be deposited in any plant tissue (roots, leaves, wood, flowers, fruits and seeds) within cells or in extracellular spaces where it then solidifies. When plants die and decay, the more durable phytoliths are deposited into the soil. If soil conditions are right and if soil layers are buried, the phytoliths contained within will also be preserved as fossils in rocks many millions of years old.
Grasses are the most well-known of silica accumulating plants, but many other plants also produce phytoliths including mosses, ferns, gymnosperms, other monocots (eg. palms and gingers) and many species of dicotyledonous angiosperms.
Here is a useful graphic to understand how silica fills leaf epidermal cells of leaves other than grasses which can eventually come to be fossils.