Typically through the fossilized teeth.
The isotopes within as well.
For instance, plant eaters had more rounded teeth, meat eaters had more sharp teeth.
They are learning more and more as we go.
This link shows where we were and where we are going with determining ancient diets, whether it be dinosaur or other, the science still applies.
https://news.climate.columbia.edu/2018/06/27/study-signals-change-in-how-scientists-calculate-ancient-diets/
Latest Answers