Skip to content

Importance of Doctypes and browser behaviour

February 18, 2007

I was trying to center a DIV today and couldn’t figure out why it wasn’t working as expected in IE7.
To center a DIV, you can use CSS and set the margin-left, margin-right to auto and give the DIV a fixed width. However, a bug in IE6 required that you also set the text-align of the body to center.

I noticed that homepage didn’t need this text-align workaround and didn’t know why. The reason turned out to be the DOCTYPE that was used. Using this DOCTYPE, you don’t need that text-align hack.

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “”&gt;


Quicks mode and strict mode


From → Web Development

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: