For as long as I've been validating web pages, I never realized that the closing </head> tag was optional in HTML. I feel as if I've missed the boat at times.

While I'm all for trimming excess code, I just cannot for the life of me strip out closing tags because they are optional in HTML. I'd be concerned that something, somewhere would not parse the document correctly if I removed the closing </head> element.

Are my concerns unfounded?

Recommended Answers

All 4 Replies

Your concerns are valid. All tags should be closed (must be closed in XHTML).

Don't feel that you missed the boat; that was probably a boat you were better off missing anyway. It's good to get into the habit of writing correct code; breaking the habit of writing bad code is difficult.

Depending on your DOCTYPE declaration, this may raise concerns. As PKern states, closing tags are required in xhtml.

Although trimming access code saves you in bandwidth usage, this could make the difference between forcing the browser to go into quirks mode or standards mode. Browsers perform better in standards mode because the parsing requires less overhead. You can find out more about this by google-ing "Quirks Mode vs. Standards Mode".

I.e. Trimming code benefits you; good code benefits the user. If done correctly, trimming code benefits you and the end user.

If you want to save bandwidth by cutting out access code, you can start by cutting out unnecessary white space. This helps dramatically, while still preserving code correctness.

this is the first time i m hearing of tags being optional, and luckily too.
i m way too used to closing tags and if i had know that sooner, i most probably would of not closed a lot of tags and become a sloppy programmer.

all tags musty closed

Thanx,
Sree

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.