Is this valid code?

J

Jim Higson

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.
 
D

David Dorward

Jim said:
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.
 
B

Brian Cryer

Jim Higson said:
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.
 
A

Andy Dingley

Jim said:
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.
 
B

Benjamin Niemann

Andy said:
"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.
 
A

Andy Dingley

Benjamin said:
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).
 

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

Forum statistics

Threads
473,999
Messages
2,570,246
Members
46,839
Latest member
MartinaBur

Latest Threads

Top