Re: End tags in HTML
- From: Kam-Hung Soh <kamhung.soh@xxxxxxxxx>
- Date: Tue, 8 Apr 2008 17:11:07 -0700 (PDT)
On Apr 9, 8:07 am, Richard Heathfield <r...@xxxxxxxxxxxxxxx> wrote:
gw7...@xxxxxxx said:
I was under the impression that one of the features of HTML was that
you could use pairs of tags, such as <tag> and <\tag>,
You mean </tag>
to mark off a
particular area. I thought this was neat. Indeed, I have written a
program that, when it saves its data, uses just such pairs of tags to
delimit the data and say what it is.
To my total surprise, I found out on Monday that I was wrong. Both XML
and HTML use a forward slash, not a back slash, to indicate an end
tag.
Right.
Has either of these ever used a backslash in an end tag?
I don't think so, no.
Or have I mis-read every single end tag I have ever seen?
It would appear so. :-)
Is there something else
similar that I could possibly have been getting confused with?
Most obvious explanation: the *first* HTML page you saw was written by
someone who got this wrong by using <\foo> to close a tag, and since then
you've blithely assumed that either / or \ is acceptable. This is
plausible only because browsers have always been remarkably adept at
accepting poorly formed HTML.
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Browsers used to, and still, accept badly formed HTML. If you load an
HTML file with this text in Firefox or MSIE6 ...
<h1>Blah
<p>More blah
.... they will display:
Blah
More blah
However, if you use backslash instead of forward slash in your
tags ...
<h1>Blah<\h1>
<p>More blah<\p>
.... these browsers display the bogus tags as text:
Blah<\h1>
More blah<\p>
So it's unlikely that OP first encountered the bogus closing tags in
HTML files.
It's an intriguing mystery!
--
Kam-Hung Soh <a href="http://kamhungsoh.com/blog">Software Salariman</
a>
.
- References:
- End tags in HTML
- From: gw7rib
- Re: End tags in HTML
- From: Richard Heathfield
- End tags in HTML
- Prev by Date: Re: End tags in HTML
- Next by Date: Re: End tags in HTML
- Previous by thread: Re: End tags in HTML
- Next by thread: Re: End tags in HTML
- Index(es):
Relevant Pages
|