What is the easiest way to horizontally center a div using CSS? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

What is the easiest way to horizontally center a div using CSS?

danielm77danielm77 USAPosts: 72Member

I need to horizontally center a fixed width div. What is the easiest way of doing this using CSS?

Comments

  • DavidMDavidM USAPosts: 342Member
    edited March 2014

    Stylesheet

    div.yourDiv
        {
          width: 500px;
          display: block;
          margin-left: auto;
          margin-right: auto;
        }

    HTML
    <div class="yourDiv">Your content here</div>

Sign In or Register to comment.