Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 18th, 2007, 11:13 AM   #11
ExplainThat
Newbie
 
Join Date: Sep 2007
Posts: 5
Rep Power: 0 ExplainThat is on a distinguished road
Re: Optional Closing Tags in HTML

Quote:
Originally Posted by cscgal View Post
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>
  <li>One.
  <li>Two.
</ul>
This is wrong, but it's impossible for something to be a part of two list elements of the exact same list, so a web browser will implicitely close the first list element before moving on to the second one. If you get into this habit, you'll inevitably not close something that technically could remain open (and therefore the browser won't be nice enough to close it for you), even though it's incorrectly nested or not what you intended.
I agree wholeheartedly - I was just suggesting a way to check on when it might be safe to leave out a closing tag for those who wish to do that. The reasoning being that if Google can get away with it chances are it works in most browsers.
__________________
http://www.explainth.at
ExplainThat is offline   Reply With Quote
Old Oct 18th, 2007, 11:16 AM   #12
cscgal
Hobbyist Programmer
 
cscgal's Avatar
 
Join Date: Oct 2007
Location: New York
Posts: 163
Rep Power: 10 cscgal is on a distinguished road
Re: Optional Closing Tags in HTML

Google can get away with a lot of things that us commonfolk can't.
__________________
DaniWeb IT Discussion Community
Everything Information Technology related all in one convenient interactive online publication and community
cscgal is offline   Reply With Quote
Old Oct 18th, 2007, 3:01 PM   #13
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Re: Optional Closing Tags in HTML

Let me relate this issue to another of the same variety. Many compilers will accept "void main ...". Some compilers will also accept "fflush (stdin);". Others will accept "rewind (stdin);".

These are proprietary solutions that detect the difference between input buffers and output buffers and deal with them accordingly. Any reasonably proficient programmer, given a knowledge of the underlying implementation, can achieve solutions for these "problems".

C and C++ chose not to address, directly, implementation issues. I personally believe that this is the correct approach. There's little doubt that this personal opinion is connected to the fact that I have built many systems with many kinds of keyboards and displays, and even systems without (except in test/debug modes) keyboards and displays, at all.

The bottom line is that performance, however widespread, does not dictate the standards. Standards define compliance. Anything that does not meet the standards is non-compliant, unless the standard explicitly denotes freedom in the area, by deliberately not defining or not specifying some particular response.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Oct 18th, 2007, 4:40 PM   #14
cscgal
Hobbyist Programmer
 
cscgal's Avatar
 
Join Date: Oct 2007
Location: New York
Posts: 163
Rep Power: 10 cscgal is on a distinguished road
Re: Optional Closing Tags in HTML

I was right! I predicted on my post on page one: I feel a C++ void main() lecture coming on ...
__________________
DaniWeb IT Discussion Community
Everything Information Technology related all in one convenient interactive online publication and community
cscgal is offline   Reply With Quote
Old Oct 18th, 2007, 6:48 PM   #15
WaltP
Programmer
 
Join Date: Oct 2007
Posts: 39
Rep Power: 0 WaltP is on a distinguished road
Re: Optional Closing Tags in HTML

Quote:
Originally Posted by cscgal View Post
I was right! I predicted on my post on page one: I feel a C++ void main() lecture coming on ...
Gee, she's psychoti... er... psychic!
WaltP is offline   Reply With Quote
Old Oct 18th, 2007, 10:45 PM   #16
joeprogrammer
Newbie
 
joeprogrammer's Avatar
 
Join Date: Apr 2007
Location: Canada
Posts: 4
Rep Power: 0 joeprogrammer is on a distinguished road
Re: Optional Closing Tags in HTML

Quote:
Originally Posted by ExplainThat View Post
I tend not to leave out closing tags even when I know that it works. However, on the rare occassion that I have to I check to see what Google is doing - just take a look at their SERPs. There are tons of missing closing tags - for instance, they hardly ever close a listitem. The way I figure, if Google is skipping a closing tag then it should generally be safe with most browsers since I cannot imagine that they would leave any browser that could possibly matter out in the cold.
MSDN has a lot of code examples that use void main. Does that mean it's okay to follow Microsoft's example, too?

Personally, I agree with Dani. The stricter you conform to the standards, the less likely you're going to screw up, and the less likely your website is going to screw up on some crap browser.
__________________
Duh.
joeprogrammer is offline   Reply With Quote
Old Oct 19th, 2007, 1:12 AM   #17
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 754
Rep Power: 3 Jimbo is on a distinguished road
Re: Optional Closing Tags in HTML

Standards compliance is also becoming a Good Thang(TM) in the industry as well, so we'll likely see many improvements in that so that there's less issue about those "some crap browsers" out there.
__________________
<insert disclaimer here>
<insert shameless plug for Visual Studio here>
Jimbo is online now   Reply With Quote
Old Dec 26th, 2007, 1:47 PM   #18
funcravers
Newbie
 
funcravers's Avatar
 
Join Date: Dec 2007
Posts: 5
Rep Power: 0 funcravers is on a distinguished road
Re: Optional Closing Tags in HTML

It's a bad habit not to close any tag. The only tag I don't close is the <HTML> tag because I always forget when I'm finished with editing a webpage.
funcravers is offline   Reply With Quote
Old Dec 26th, 2007, 5:55 PM   #19
Kuryn
Newbie
 
Join Date: Dec 2007
Posts: 14
Rep Power: 0 Kuryn is on a distinguished road
Re: Optional Closing Tags in HTML

Well, at least Microsoft is making up for it in Internet Explorer 8 since it did pass the Acid2 test, even though it don't really matter. All the Acid2 test passing for developers. Not like it will matter to the non-developers.

And it sucks that people have to have all CAP tags which is badly designed, or optional "" in the attributes, to optionally omit end tags.
Kuryn is offline   Reply With Quote
Old Dec 26th, 2007, 10:45 PM   #20
cscgal
Hobbyist Programmer
 
cscgal's Avatar
 
Join Date: Oct 2007
Location: New York
Posts: 163
Rep Power: 10 cscgal is on a distinguished road
Re: Optional Closing Tags in HTML

Quote:
Originally Posted by funcravers View Post
It's a bad habit not to close any tag. The only tag I don't close is the <HTML> tag because I always forget when I'm finished with editing a webpage.
Isn't that like the worst tag to forget?
__________________
DaniWeb IT Discussion Community
Everything Information Technology related all in one convenient interactive online publication and community
cscgal is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
start Learning HTMl smita HTML / XHTML / CSS 0 Mar 15th, 2007 7:38 AM
converting string to float beginnerCCC C 22 Oct 2nd, 2006 11:59 PM
Basics of HTML Tutorial crawforddavid2006 HTML / XHTML / CSS 14 Jul 11th, 2006 7:40 AM
Basic HTML Tutorial - Reuben Keeney ReubenK HTML / XHTML / CSS 14 Mar 26th, 2006 5:50 AM
HTML =/= Programming Sane Coder's Corner Lounge 32 Mar 8th, 2006 2:50 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:45 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC