471,066 Members | 1,273 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,066 software developers and data experts.

HTML standard tags.

When I was first taught html several years ago, I was taught that the
following tags are standard for any html formatted message:
<HTML>
<HEAD>
</HEAD>
</BODY>
</HTML>

In fact, I was taught that the opening tags (not the ones with </) are
mandatory tags.

However, I am stumped by the fact that I can create an html document
without the existence of any of these tags and still view it correctly
in a web browser.

Is this because the html standard (if there is such a thing) has
changed or have web browsers become more forgiving?
Jul 20 '05 #1
6 3291
In post <8d**************************@posting.google.com >
Ludwig77 said...
When I was first taught html several years ago, I was taught that the
following tags are standard for any html formatted message:
<HTML>
<HEAD>
</HEAD>
</BODY>
</HTML>


the opening and closing tags of those elements are optional although
the recommendations do say the head and body of a html document should
be delimited by those tags.


--
brucie a. blackford. 01/August/2003 10:37:08 pm kilo.
http://loser.brucies.com/
Jul 20 '05 #2
In post <17****************@alt-html.org>
brucie said...
<HTML>
<HEAD>
</HEAD>
</BODY>
</HTML>
the opening and closing tags of those elements are optional although
the recommendations do say the head and body of a html document should
be delimited by those tags.

^^^^^^^^^^^^ the html element
--
brucie a. blackford. 01/August/2003 11:02:58 pm kilo.
http://loser.brucies.com/
Jul 20 '05 #3
Ludwig77 wrote:
When I was first taught html several years ago, I was taught that the
following tags are standard for any html formatted message:
<HTML>
<HEAD>
</HEAD>
</BODY>
</HTML>

In fact, I was taught that the opening tags (not the ones with </) are
mandatory tags.
This is incorrect for HTML. The _elements_ are always present, but the
_tags_ don't have to be, at least for HTML. Don't take my word for it
though, feel free to read the specifications yourself. The latest version
of HTML is 4.01:

<URL:http://www.w3.org/TR/html401/>

<URL:http://www.w3.org/TR/html401/struct/global.html#edef-HTML>
<URL:http://www.w3.org/TR/html401/struct/global.html#edef-HEAD>
<URL:http://www.w3.org/TR/html401/struct/global.html#edef-BODY>

What is _not_ optional, however, is the <title> element:

<URL:http://www.w3.org/TR/html401/struct/global.html#edef-TITLE>

HTML 4.01 also requires a doctype declaration:

<URL:http://www.w3.org/TR/html401/struct/global.html#h-7.2>

In practice, most people put them in. There may well be software out there
that isn't very good at understanding HTML, and requires that these tags be
present. XHTML has different rules, so if you are interested in writing
XHTML documents, you'll have to investigate further.

However, I am stumped by the fact that I can create an html document
without the existence of any of these tags and still view it correctly
in a web browser.
Bear in mind that just because something works for you, it doesn't mean that
it will work for your visitors. For instance, if you make the mistake of
serving your HTML files as text/plain, and are able to view it "correctly"
(or, to be more specific, *how you expect*), all that means is people using
Internet Explorer can view it "correctly" (since the browser gets HTTP
wrong), and people using other browsers are shut out.

Is this because the html standard (if there is such a thing) has
changed or have web browsers become more forgiving?


The details above are also correct for HTML 3.2 and HTML 2.0.

Browsers vary in how "forgiving" they are. Some browsers get stricter and
new browsers appear that are stricter, but sometimes the reverse is also
true.

Any sensible author would adhere to the published specifications to avoid
getting caught out when browsers change behaviour in error conditions. You
will never be able to test in all significant user-agents that access a WWW
document. Google is a good example.

For instance, just recently in this newsgroup, somebody was talking about a
document that had been authored seven years ago that used code similar to
the following:

<a href=mailto:us**@example.com>

This fails in Safari - which didn't even exist when the document was first
authored. Fixing the code so that it conformed to the specifications
solved the problem. Will user-agents have the same error handling in the
year 2010 as they do today? I wouldn't bet on it. What about user-agents
in use *today* that you don't know anything about?

More examples can be found here:

<URL:http://www.evolt.org/article/Forward_compatibility_and_web_standards/17/60115/index.html#comment60184>

--
Jim Dabell

Jul 20 '05 #4
Ludwig77 wrote:
When I was first taught html several years ago, I was taught that the
following tags are standard for any html formatted message:
I would hope you meant "document" here. HTML e-mail and news postings are
frowned upon in a lot of contexts.
<HTML>
<HEAD>
</HEAD>
</BODY>
</HTML>
(I assume you meant to include <BODY> in the fourth slot above.)
In fact, I was taught that the opening tags (not the ones with </) are
mandatory tags.

However, I am stumped by the fact that I can create an html document
without the existence of any of these tags and still view it correctly
in a web browser.
It is poor practice to leave these tags out. In HTML 4.01 you can leave them
out and the existence is implied. However, in XHTML 1.0 and later (IIRC)
you can't get away with this.
Is this because the html standard (if there is such a thing) has
changed or have web browsers become more forgiving?


I would call this error recovery even though it is technically allowed.
Never depend on error recovery; it will bite you when you are least
expecting it.

--
Shawn K. Quinn
Jul 20 '05 #5
In post <5c********************@speakeasy.net>
Shawn K. Quinn said...

[omitting optional opening/closing tags]
I would call this error recovery even though it is technically allowed.
Never depend on error recovery; it will bite you when you are least
expecting it.


wouldn't a browser invoking error recovery for something that isn't
broken be itself broken?

--
brucie a. blackford. 02/August/2003 10:56:20 pm kilo.
http://loser.brucies.com/
Jul 20 '05 #6
"Shawn K. Quinn" <sk*****@xevious.kicks-ass.net> wrote in message news:<5c********************@speakeasy.net>...
Ludwig77 wrote:
When I was first taught html several years ago, I was taught that the
following tags are standard for any html formatted message:


I would hope you meant "document" here. HTML e-mail and news postings are
frowned upon in a lot of contexts.
<HTML>
<HEAD>
</HEAD>
</BODY>
</HTML>


(I assume you meant to include <BODY> in the fourth slot above.)
In fact, I was taught that the opening tags (not the ones with </) are
mandatory tags.

However, I am stumped by the fact that I can create an html document
without the existence of any of these tags and still view it correctly
in a web browser.


It is poor practice to leave these tags out. In HTML 4.01 you can leave them
out and the existence is implied. However, in XHTML 1.0 and later (IIRC)
you can't get away with this.
Is this because the html standard (if there is such a thing) has
changed or have web browsers become more forgiving?


I would call this error recovery even though it is technically allowed.
Never depend on error recovery; it will bite you when you are least
expecting it.


Yes, I meant document and yes, I meant <body>.

Thanks,

Greg
Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Peter Valdemar M?rch | last post: by
5 posts views Thread by Donald Firesmith | last post: by
8 posts views Thread by Marc Rochkind | last post: by
4 posts views Thread by Deepak Mehta | last post: by
9 posts views Thread by Jason Gogela | last post: by
4 posts views Thread by Arthur Dent | last post: by
15 posts views Thread by lxyone | last post: by
reply views Thread by Guy Macon | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.