How to fix element not centering with margin: 0 auto with CSS?

Spread the love

Sometimes, we want to fix element not centering with margin: 0 auto with CSS.

In this article, we’ll look at how to fix element not centering with margin: 0 auto with CSS.

How to fix element not centering with margin: 0 auto with CSS?

To fix element not centering with margin: 0 auto with CSS, we use text-align instead of margin.

For instance, we write

#header {
  text-align: center;
}

#header ul {
  display: inline;
}

to center the element with ID header with text-align: center;.

Conclusion

To fix element not centering with margin: 0 auto with CSS, we use text-align instead of margin.

Leave a Reply

Your email address will not be published.