0

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">

3
  • What goes wrong with the original doctype? What browsers are you using to test? Commented Apr 26, 2010 at 19:04
  • if I open that page using IE8 the inner DIV is align left. Commented Apr 26, 2010 at 19:08
  • Actually, that is working on Chrome, Firefox, Safari and Opera, but not on IE. Welcome to the club. Commented Apr 26, 2010 at 19:11

2 Answers 2

1

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...

Sign up to request clarification or add additional context in comments.

4 Comments

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.
If that's the only issue, couldn't you just add text-align: left; to the #inner?
No I can't because there is lots of other things inside that div:(
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
0

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.