h1 and h2 are block level elements so by default they are 100% wide. Instead of all of the complex calculation, simply use text-align: center;
h1
h2
text-align: center;
1.4m articles
1.4m replys
5 comments
57.0k users