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