closing the link tag in HTML strict

P

petermichaux

Hi,

When I validate a HTML 4.01 STRICT document it doesn't like to see a
closed tag like this

<link rel="stylesheet" href="base.css" type="text/css"/>

but it is happy with

<link rel="stylesheet" href="base.css" type="text/css">

Does anyone know why the link cannot be closed in HTML? It seems
strange if HTML 4.01 is supposed to be closely parallel with XHTML.

Thanks,
Peter
 
J

Jukka K. Korpela

Scripsit (e-mail address removed):
When I validate a HTML 4.01 STRICT document it doesn't like to see a
closed tag like this

<link rel="stylesheet" href="base.css" type="text/css"/>

Of course it doesn't "like" it, since the ">" character data is invalid in
Does anyone know why the link cannot be closed in HTML?

Of course the <link> element can and must be closed in HTML. It is
self-closing, i.e. no explicit end tag is allowed, since it has EMPTY
declared content. And you actually close the <link> _tag_ (and thereby the
<link> element, too) if you use that "/" character, but then you have a
problem with the subsequent ">". See
http://www.cs.tut.fi/~jkorpela/html/empty.html
It seems
strange if HTML 4.01 is supposed to be closely parallel with XHTML.

They are two different syntaxes. It is absurd to use one and expect it to
validate under the other.

Just don't mix good old HTML and XHTML, mm'kay? Actually, just don't put any
XHML on the web before at least the most common browser supports it, mm'kay?
 
B

Benjamin Niemann

Hello,

When I validate a HTML 4.01 STRICT document it doesn't like to see a
closed tag like this

<link rel="stylesheet" href="base.css" type="text/css"/>

but it is happy with

<link rel="stylesheet" href="base.css" type="text/css">

Does anyone know why the link cannot be closed in HTML?

LINK has the content model EMPTY - this means that it cannot have any
content and must not have an end-tag.

<ELEM .. /> is a short-hand for <ELEM ..> .. </ELEM> *in XML*, but HTML is
based on SGML, which does not have such a syntax (it does have a similar
looking syntax with a complete different meaning).
XML introduced this short-hand syntax, because it does not know the content
model EMPTY, but elements without content are pretty often used.
It seems
strange if HTML 4.01 is supposed to be closely parallel with XHTML.

HTML 4.01 is older than XHTML and it was never supposed to have anything in
common with XHTML. XHTML 1.0 on the other hand was supposed to be a
semantically equal reformulation of HTML 4.01 with the slightly different
XML syntax rules.

HTH
 
P

petermichaux

Benjamin said:
Hello,



LINK has the content model EMPTY - this means that it cannot have any
content and must not have an end-tag.

<ELEM .. /> is a short-hand for <ELEM ..> .. </ELEM> *in XML*, but HTML is
based on SGML, which does not have such a syntax (it does have a similar
looking syntax with a complete different meaning).
XML introduced this short-hand syntax, because it does not know the content
model EMPTY, but elements without content are pretty often used.


HTML 4.01 is older than XHTML and it was never supposed to have anything in
common with XHTML. XHTML 1.0 on the other hand was supposed to be a
semantically equal reformulation of HTML 4.01 with the slightly different
XML syntax rules.

HTH

Hi Benjamin,

Thank you for the informative response. My misunderstanding was that
the XHTML reformulation was supposed to be a little closer to HTML than
it actually is.

Thanks again,
Peter
 
J

Jukka K. Korpela

Scripsit Gérard Talbot:
End Tag is forbidden for <link> in HTML 4
Correct.

<!ELEMENT LINK - O EMPTY -- a media-independent link -->
at
http://www.w3.org/TR/html4/struct/links.html#edef-LINK
when the O means that the end tag must be omitted.

Not correct. The "O" means that the end tag "omissible". It also appears
e.g. in the declaration of the <p> element, which surely _may_ have the end
tag </p>.

It is the content model EMPTY that makes the end tag disallowed. Ref.: the
SGML standard (ISO 8879), clause 7.3.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top