How to center div inside another div horizontally using CSS

CSS margin property with an auto value needs to be used, but the inner tag div must have at least some width.

CSS:

#inner {
  margin: 0 auto;
  width: 200px;
}

HTML:

Text text text

Continue reading here: Responsive typography and web design for beginners

Was this article helpful?

0 0