Add your website to the Xemion web designer directory and gain highly-targeted traffic and new leads.

Optional Closing Tags in HTML

Post Reply
 
Thread Tools
 
#1 July 7, 2007 by mr. Adam - Junior Member, 2 posts PHP: , RoR: , CSS/XHTML:  , Design: , Javascript: , ASP/.NET: , SEO: , SQL: Reputation Level
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?
 
#2 September 21, 2007 by adlercla - Junior Member, 2 posts Montreal, PHP: , RoR: , CSS/XHTML:  , Design: , Javascript: , ASP/.NET: , SEO: , SQL: Reputation Level
when you validate a page without </head> at: http://validator.w3.org/ it will generate an error.
cloo
Quote
 
#3 December 23, 2007 by MBS - Junior Member, 9 posts PHP: , RoR: , CSS/XHTML:  , Design: , Javascript: , ASP/.NET: , SEO: , SQL: Reputation Level
It will work without it in a browser, but it is still incorrect. Some browsers would probably display properly with just the <html></html> tags and no <head> or <body>.
 
#4 December 23, 2007 by BertK - Junior Member, 18 posts PHP: , RoR: , CSS/XHTML:  , Design: , Javascript: , ASP/.NET: , SEO: , SQL: Reputation Level
Don't strip out </head>, </body> or </html> closing tags - it may hurt compatibility and you end up with a site that won't load.
 
#5 December 23, 2007 by OS Master - Junior Member, 6 posts PHP: , RoR: , CSS/XHTML:  , Design: , Javascript: , ASP/.NET: , SEO: , SQL: Reputation Level
It depends on how the browser parses the source code. I would think it's a very good idea to close all your tags, since XHTML requires that you do so.

If you want your code validated, you do need to close the tags.
 
#6 December 30, 2007 by mrsyardbroom - Junior Member, 8 posts PHP: , RoR: , CSS/XHTML:  , Design: , Javascript: , ASP/.NET: , SEO: , SQL: Reputation Level
I agree. I was taught to close all HTML tags by an HTML guru who still codes everything by hand. He maintained that by not closing some tags you develop lazy habits which ultimately leads to errors. There's nothing worse than staring at a page of code and wondering where you went wrong.
 
#7 January 7, 2008 by matt123 - Junior Member, 9 posts PHP: , RoR: , CSS/XHTML:  , Design: , Javascript: , ASP/.NET: , SEO: , SQL: Reputation Level
y that is also not in the html coding standards to leave out closing tags but for tr td tags of table & few others closing tags don't make them look illogical as they do in case of removing closing head
 
#8 October 19, 2008 by cassiem0221 - Member, 38 posts PHP: , RoR: , CSS/XHTML:  , Design: , Javascript: , ASP/.NET: , SEO: , SQL: Reputation Level
Regardless of whether or not the web site is displayed properly to you when you leave out closing tags, you never know what browser the next person will be using. You take the risk of having a poorly displayed site OR one that doesn't display at all. I'm sure the closing tags serve a purpose or else they wouldn't have been developed
Post Reply

Thread Tools