closing the link tag in HTML strict

Discussion in 'HTML' started by petermichaux@gmail.com, Oct 2, 2006.

  1. Guest

    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
     
    , Oct 2, 2006
    #1
    1. Advertising

  2. Scripsit :

    > 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
    the context where the <link> element is allowed. What did you expect a
    validator to do if not validate?

    > 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?

    --
    Jukka K. Korpela ("Yucca")
    http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, Oct 2, 2006
    #2
    1. Advertising

  3. Hello,

    wrote:

    > 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

    --
    Benjamin Niemann
    Email: pink at odahoda dot de
    WWW: http://pink.odahoda.de/
     
    Benjamin Niemann, Oct 2, 2006
    #3
  4. =?ISO-8859-1?Q?G=E9rard_Talbot?=, Oct 2, 2006
    #4
  5. Guest

    Benjamin Niemann wrote:
    > Hello,
    >
    > wrote:
    >
    > > 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


    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
     
    , Oct 2, 2006
    #5
  6. 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.

    --
    Jukka K. Korpela ("Yucca")
    http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, Oct 2, 2006
    #6
  7. Jukka K. Korpela wrote :
    > Scripsit Gérard Talbot:
    >
    >> 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>.
    >


    Argh... you're right:

    "(...) the letter "O" indicates that the end tag can be omitted."
    http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.3.3

    I stand corrected. Thanks! :)

    Gérard
    --
    remove blah to email me
     
    =?ISO-8859-1?Q?G=E9rard_Talbot?=, Oct 3, 2006
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. shruds
    Replies:
    1
    Views:
    893
    John C. Bollinger
    Jan 27, 2006
  2. Nik Coughlin
    Replies:
    0
    Views:
    427
    Nik Coughlin
    Jun 16, 2006
  3. Replies:
    1
    Views:
    411
    Andrew Thompson
    Nov 29, 2006
  4. Aniais
    Replies:
    5
    Views:
    611
    Joe (GKF)
    Dec 17, 2006
  5. jwcarlton

    Removing tag + closing tag

    jwcarlton, Sep 21, 2010, in forum: Perl Misc
    Replies:
    12
    Views:
    187
Loading...

Share This Page