define('DISALLOW_FILE_EDIT', true); define('DISALLOW_FILE_MODS', true); How to centre an element in CSS | WP Hosting

How to centre an element in CSS

In the olden days of HTML development, in the late 90ies, we only had inline styles. Centring an element was done using the <center> property. That approach isn’t very elegant anymore in modern CSS 🙂

Today we can use something like this:

#your-id .your-class {
    display: block;
    margin-left: auto;
    margin-right: auto;
}

It’s slightly more complicated than a single tag, but also opens up more options to tweak top and bottom margins at the same time.

You can leave a comment on my original post.