How to Center a Div Tag

February 6th, 2010 by Eric Rowell

It seems like a lot of people have confusion about centering a div tag these days (which is totally understandable because different techniques can yield different results in IE and Firefox).  The most common way of centering a div tag is to do something like this:

<div style="text-align: center;">
<div style="margin-left: auto; margin-right: auto;">
         Hello World</div>
</div>

Hope this helps!

Additional reading

  • No Related Post

Leave a Reply