Skip to content
February 25, 2011 / Rohit


HTML as a language is very lax. It’s unlike any of the programming languages, wherein you are not punished for committing syntax errors. Even if you have unclosed tags, malformed HTML or other syntax errors, your web-browser may still render the page correctly,. The browsers handle these errors, because the number of such web-pages is still high.

When I first learned HTML, the most basic tag which I came to know of was the <html> tag. It was supposed to be the first tag which you typed to write any web-page. And I have been creating web pages which started with the <html> all along. And all those pages have never been standards compliant, because they never had a <!DOCTYPE> tag.

The first thing which you should always write in your HTML document the <!DOCTYPE> tag. It’s necessary for browsers to render your page in a standards mode. Otherwise the browser will render your page in quirks mode and the rendering can change from browser to browser.

For HTML 4.01, your doctype should look like:


For XHTML, it should be:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

For HTML5 it’s (and that’s another reason to love HTML5):

<!doctype html>

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: