Is this valid code?

Discussion in 'HTML' started by Jim Higson, Jun 11, 2006.

  1. Jim Higson

    Jim Higson Guest

    I just noticed that not separating attributes by spaces is picked up by some
    validators/checkers and not others.

    For example, this code:

    <a title="a link"href="http://example.com">this is a link</a>

    Flags no errors with the W3C checker, but the one at
    http://www.htmlvalidator.com/lite/ says "A quoted string (like an attribute
    value) cannot be immediately followed by text. It must be followed by a
    space or by the end of the tag. Is there a missing space character?"

    This is in an XHTML document (although I'd be interested to see what the
    rules are for HTML 4 as well). Is anyone familiar enough with the SGML
    specification of XML to say if the example I gave is valid XML?

    No real point to this, just wondering which validator gets it right.

    --
    Jim
    Jim Higson, Jun 11, 2006
    #1
    1. Advertising

  2. Jim Higson wrote:

    > I just noticed that not separating attributes by spaces is picked up by
    > some validators/checkers and not others.


    > For example, this code:
    >
    > <a title="a link"href="http://example.com">this is a link</a>
    >
    > Flags no errors with the W3C checker


    Which does warn that it has some limitations when dealing with XML:

    http://openjade.sourceforge.net/doc/xml.htm

    "XML does not allow a parameter separator that is adjacent to a delimiter to
    be omitted."

    > This is in an XHTML document (although I'd be interested to see what the
    > rules are for HTML 4 as well).


    I believe it is allowed in HTML.

    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
    David Dorward, Jun 11, 2006
    #2
    1. Advertising

  3. Jim Higson

    Brian Cryer Guest

    "Jim Higson" <> wrote in message
    news:...
    > I just noticed that not separating attributes by spaces is picked up by

    some
    > validators/checkers and not others.
    >
    > For example, this code:
    >
    > <a title="a link"href="http://example.com">this is a link</a>
    >
    > Flags no errors with the W3C checker, but the one at
    > http://www.htmlvalidator.com/lite/ says "A quoted string (like an

    attribute
    > value) cannot be immediately followed by text. It must be followed by a
    > space or by the end of the tag. Is there a missing space character?"
    >
    > This is in an XHTML document (although I'd be interested to see what the
    > rules are for HTML 4 as well). Is anyone familiar enough with the SGML
    > specification of XML to say if the example I gave is valid XML?
    >
    > No real point to this, just wondering which validator gets it right.


    I don't know whether it is or might be right (David Dorward's post seems to
    address that point reasonably well), but I would expect that some bots would
    fail to parse it correctly. So it may have an adverse effect on search
    engine rankings.
    --
    Brian Cryer
    www.cryer.co.uk/brian
    Brian Cryer, Jun 12, 2006
    #3
  4. Jim Higson

    Andy Dingley Guest

    Jim Higson wrote:
    > I just noticed that not separating attributes by spaces is picked up by some
    > validators/checkers and not others.


    "Any number of (legal) attribute value pairs, separated by spaces, may
    appear in an element's start tag."
    http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2
    So you do need the spaces in HTML (inc Appendix C XHTML).

    The production for attributes in XML
    http://www.w3.org/TR/2004/REC-xml11-20040204/#sec-starttags
    also requires spaces, so you require them in XML, including XHTML as
    application/xhtml+xml.

    I offer no explanation of the W3C's parser not reporting the
    well-formedness error. I don't think this is some SGML subtlety (which
    would be forbidden by ther text of the HTML TR anyway). It's probably
    another manifestation of the less than perfect nature of the W3C
    validator when used on XML-as-XML.
    Andy Dingley, Jun 12, 2006
    #4
  5. Andy Dingley wrote:

    >
    > Jim Higson wrote:
    >> I just noticed that not separating attributes by spaces is picked up by
    >> some validators/checkers and not others.

    >
    > "Any number of (legal) attribute value pairs, separated by spaces, may
    > appear in an element's start tag."
    > http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2
    > So you do need the spaces in HTML (inc Appendix C XHTML).


    Chapter 3 "On SGML and HTML" is not a normative specification of the SGML
    syntax. (Would be great, if SGML was so simple that it could be described
    in this single chapter ;) )

    > The production for attributes in XML
    > http://www.w3.org/TR/2004/REC-xml11-20040204/#sec-starttags
    > also requires spaces, so you require them in XML, including XHTML as
    > application/xhtml+xml.


    XML is stricter than SGML. And one of the problems of the w3c validator is
    that the parser (still) uses (some) SGML rules when it processes XHTML.
    That's why it is currently not reporting such syntax errors is XHTML.

    > I offer no explanation of the W3C's parser not reporting the
    > well-formedness error. I don't think this is some SGML subtlety


    It is. The space is optional as long as it is unambiguous.

    > (which
    > would be forbidden by ther text of the HTML TR anyway).


    The w3c validator is just a (slightly tuned) SGML validator. It does not
    know any special HTML rules (even if the spaces were mandatory in HTML).

    > It's probably
    > another manifestation of the less than perfect nature of the W3C
    > validator when used on XML-as-XML.


    Yup.

    --
    Benjamin Niemann
    Email: pink at odahoda dot de
    WWW: http://pink.odahoda.de/
    Benjamin Niemann, Jun 12, 2006
    #5
  6. Jim Higson

    Andy Dingley Guest

    Benjamin Niemann wrote:
    > Andy Dingley wrote:


    > Chapter 3 "On SGML and HTML" is not a normative specification of the SGML
    > syntax. (Would be great, if SGML was so simple that it could be described
    > in this single chapter ;) )


    I never claimed it was, but I did think it was normative for HTML.
    However the intro to Chapter 4 does suggest that you're right and that
    chapter 3 _isn't_ normative (funny bloody way to run a railway, but
    there you go).
    Andy Dingley, Jun 13, 2006
    #6
    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. Replies:
    2
    Views:
    443
    Adam P. Jenkins
    Jan 18, 2005
  2. Eric Biller

    Embedding VRML-Objects in valid code

    Eric Biller, Nov 13, 2003, in forum: HTML
    Replies:
    6
    Views:
    3,754
    Toby A Inkster
    Nov 14, 2003
  3. Gianni Mariani

    is this code valid ?

    Gianni Mariani, May 17, 2004, in forum: C++
    Replies:
    5
    Views:
    361
    Gianni Mariani
    May 19, 2004
  4. Replies:
    64
    Views:
    1,253
    Dave Thompson
    Dec 20, 2004
  5. Any C code are valid C++ code?

    , Dec 10, 2004, in forum: C Programming
    Replies:
    67
    Views:
    1,169
    Dave Thompson
    Dec 20, 2004
Loading...

Share This Page