tags:

views:

64

answers:

2

If the doctype declaration is <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN"> what is the best way for horizontal alignment of the DIV's like these:

<div id="outer"><div id="inner">Some text</div></div>

The CSS is:

#outer{ border-top:1px dotted #999; background-color: #F4F4F4; width:100%;}
#inner{ width:500px;border:1px solid #F00; margin:auto;}

The thing that I want to do is the inner DIV align at center (horizontally) inside the outer DIV. This CSS working fine if the doctype declaration is <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

+1  A: 

Don't know which browser you use, but you could change

 #outer{ border-top:1px dotted #999; background-color: #F4F4F4; width:100%;} 

to:

 #outer{ border-top:1px dotted #999; background-color: #F4F4F4; width:100%; text-align:center;} 

Allthough.. I've tested your code on IE8, FireFox and Chrome and all three worked like a charm...

riffnl
The problem with text-align:center; is that the all text inside the inner div is align center as well and I want font to align left.
Sergio
If that's the only issue, couldn't you just add text-align: left; to the #inner?
Michael Herold
No I can't because there is lots of other things inside that div:(
Sergio
I don't get your last comment. You dont want the text to align to the left?You could always go for the triple-nested-what-am-i-doing-where-div-structure...whereas the outerinner div (middle) is text-aligned to the left.But I would *not* recommend it
riffnl
A: 

It seems you need to learn a bit about quirks mode.

Diodeus