html div in middle of page code example Example 1: how to center text in css .class { text-align: center; } Example 2: center text in div container text-align: center