![]() |
Optional Closing Tags in HTML
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? _________________ Parental control software free parental control software |
I didn't know this either.
I'm going to say if it works don't change it. I close all my tags because if they didn't need to be closed, there would be no closing tags, or the tag would be self closing (<br />, <hr />. Although it's good practice to write these tags as <hr /> you can write them like <br> and <hr>) I guess do whatever works. |
That's because HTML is whacky. And because of it, the parsers have to be pretty ingenious to allow for badly formed markup like that, which is partly why IE 4-6 have some really weird behaviors. Note that XHTML, which is what everybody should be using these days, doesn't allow omission of closing tags; it even requires closing tags that don't come in pairs, like <img>, <br>, and <hr>
|
The problem with XHTML is IE (non)support. That's a lot of clients. Personally, I've almost completely reverted to HTML 4.01 strict.
|
Substandard code is leading to degradation of the internet, some sites are already gettting quite bad. Take a look at Myspace.com for instance. Some of the worst HTML code ever. So bad, in fact, that my browser is no match for it's mighty crap-code, and it just freezes upon viewing.
|
Yeah, wow, I am astonished at that. XHTML is a bit more stricked though.
|
Re: Optional Closing Tags in HTML
Quote:
Quote:
Quote:
|
Re: Optional Closing Tags in HTML
Quote:
I could be wrong. Interesting thread thou. |
Re: Optional Closing Tags in HTML
Quote:
|
Re: Optional Closing Tags in HTML
As far as I am concerned, every single tag that's opened must be closed. If there is no reason for a tag to be closed (such as an image tag or line break) then it should be self closing by ending with a slash as in
<tag ... />. Just because it doesn't error out doesn't mean it's okay to do. I feel a C++ void main() lecture coming on ...--- What often happens is web browsers will implicitely add a closing tag when it is impossible for it to remain open. It's impossible to remain in the <head> section once the <body> has started, so let's implicitely close the head tag before the body. This same thing happens with lists. A lot of people type <li> at the start of a list element without closing it as so: :
<ul> |
| All times are GMT -5. The time now is 3:07 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC