Bruno Ribeiro | Resources | Centering type 🙄

Centering type 🙄

If you want to center type, give this property to its containing element:

text-align: center;

It’s as simple as that. Keep in mind that center‑aligned paragraphs are harder to read. And mixing left‑aligned and centered text makes breaks the alignment that structures the page.

Centering the page on the window

In HTML, wrap the whole content in a <div class="container"></div>.

In the CSS, give the div.container a specific width and a automatic margins on both sides:

    div.container {  
        width: XXem;  
        margin: auto;  
    }

Where, you replace XX with a value that you find best. (It’s probably between 30 and 90.)