Tuesday, November 27, 2012

HTML DTD: strict vs loose

I’ve been writing some HTML5 code lately, and at some point I faced some miscalculations of dimensions through CSS. After some research, I discovered I had my page being rendered in quirks mode. I’ve heard this expression before, but never really bothered much. What happens is that standards compliant pages should have a doctype declaration, which tells the browser the page should be rendered that way, otherwise the HTML will be rendered in a Neanderthal form, the so-called “quirks mode”. I never bothered using a doctype, because I didn’t know the real meaning of it. Until now.

Then, convinced to use a doctype, I faced another problem. There were two types for me:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
	"http://www.w3.org/TR/html4/strict.dtd">

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
	"http://www.w3.org/TR/html4/loose.dtd">
The first is called “strict”, the second is “transitional”. The strict cuts away all the deprecated tags, while the transitional is the same strict plus some stuff like iframe, which I’m using at my project. So, my page is a transitional one, and I finally found my DTD.

Good references here and here.

No comments: