For troubleshooting purposes, disable Java Script in Safari settings and see if that cools it down. Most websites require java script to be able to work properly- so disabling it isn't a real solution, but if the phone doesn't get hot with it disabled, then at least you know the culprit.
I'm using an old iPhone on an old version of iOS and it never gets hot doing anything