Home / Tips / Programming languages / Markup languages / HTML & CSS / How to center div inside another div horizontally using CSS

How to center div inside another div horizontally using CSS

CSS
 
CSS
  • Currently 0 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Rating: 0/5 (0 votes cast)

Thank you for rating!

You have already rated this page, you can only rate it once!

Your rating has been changed, thanks for rating!

Log in or create a user account to rate this page.


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:

<div class="outer"> 
  <div class="inner">Text text text</div>
</div>

 

Read also

How to set margins and paddings in CSS

How to set margins and paddings in CSS

Details about "float" property

Details about "float" property

Post comment

basicuse.net
html5_css
106160485398655174790

Quick navigation

General navigation