Posts Tagged ‘box model’

CSS: the box model

Thursday, July 9th, 2009

An interesting discovery for me recently (explaining part of the inconsistencies between IE and FF displays):

For firefox (and the W3C), the width of  a box exclude the padding and the border.
For IE till 7, it includes it by default.
So if you set for example both width and padding to a block element, it will renderer differently in both browser.

However, I just learnt that you can turn it to “standard compliant mode” by defining the proper doctype on top of your files, e.g.:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

More info:

http://msdn.microsoft.com/en-us/library/bb250395(VS.85).aspx