Tim Huffam

Dotting the I and crossing the T of I.T.

  Home  |   Contact  |   Syndication    |   Login
  129 Posts | 0 Stories | 874 Comments | 677 Trackbacks

News

Archives

Post Categories

Interesting Blogs/Links

As text-align doesn't work I use a simple work around:

.mydiv{
  width: 100%;
  left: 50%;
}

It's not perfect - but very simple and easy to understand - and you can modify it to suit. 

Seems to work ok in IE 6 & FF 2.0.

Here's another method (http://www.andybudd.com/archives/2004/02/css_crib_sheet_3_centering_a_div/index.php) - but I found it not obvious/simple enough (expecially for others who may have to maintain the css down the track - KISS)

HTH
Tim

posted on Tuesday, May 15, 2007 5:11 PM

Feedback

# re: Centering div tags using CSS 5/24/2007 4:42 PM Vineet
#global {
margin-left: auto;
margin-right: auto;
width: ...; /* mandatory to be centered */
}

<div id="global"></div>

Post Feedback

Title:
Name:
Email: (never displayed)
Url:
Comments: 
Please add 3 and 6 and type the answer here: