You were headed in the right direction with the original, it just needed to be a bit more specific. (I used text-align: center to make sure things were working, but you can of course change it.)
I recommend checking out this guide if you haven’t yet: