tags:

views:

210

answers:

1

I have a setup similar to below:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml”&gt;

<div id=“a” style=“width: 100%”>
<div id=“b” style=“width: 200px; margin: 0 auto”>
</div>
</div>

And this centres fine in everything except IE.

Anyone have any idea what is going on and how to fix it. I know of the text-align trick, but there must be a better method. I hate sloppy code :-)

Cheers

A: 

Text-align trick is something I've used. I hate sloppy code too, but hey, it's IE.

Something that comes to my mind is that maybe you need to set the width to all elements outside it. Try setting width to html and body too.

You're missing your body tag, you noticed that, as your code is so far away from valid, this must be just an example right?

Mikko Tapionlinna