Howdy, Stranger!

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


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

danielm77danielm77 USAMember Posts: 72

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


  • DavidMDavidM USAMember Posts: 342
    edited March 2014

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

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

Sign In or Register to comment.