By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,948 Members | 1,857 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,948 IT Pros & Developers. It's quick & easy.

W3C Validator error? <br /> is valid for doctype HTML 4.01 Strict

P: n/a
Hi everyone,

Is the W3C HTML Validator [1] in error when it returns <br /> as valid
for HTML 4.01 Strict doctype?

In March 2004 [2], the Validator returned <br />, <hr /> and <img />
as invalid for HTML 4.01 Strict.

Liam Quinn said [2] "You can't mix HTML and XHTML. You need to choose
one or the other syntax."
[meaning: choose <br> for HTML and <br /> for XHTML]

As for today, the Validator returns <br /> and <img /> as valid for
HTML 4.01 Strict, but <hr /> (and also <meta /> and <link />)
as invalid.

It seems that the Validator has changed its behaviour since 2004.

[1] http://validator.w3.org/
[2] http://lists.w3.org/Archives/Public/...r/2003Mar/0028
Liam Quinn is a founding member of WDG (Wed Desing Group).

Thanks,
Thomas Jedenfelt
Tyres÷ (Stockholm), Sweden

Jul 24 '05 #1
Share this Question
Share on Google+
12 Replies


P: n/a
th****************@operamail.com wrote:
Is the W3C HTML Validator [1] in error when it returns <br /> as
valid for HTML 4.01 Strict doctype?
No, because <br /> is valid (and equivalent to <br >>).
In March 2004 [2], the Validator returned <br />, <hr /> and <img
/> as invalid for HTML 4.01 Strict.
No, you misunderstood - which is understandable, since the statement
was not very clearly formulated.

The reason why <br /> is valid is that wherever <br> is allowed, it may
be followed by character data, so <br>> is valid too. But <hr /> is
often not allowed in HTML 4.01 Strict. If you have
<body>
<hr>>
</body>
then <hr> is OK (hr is a block level element) but > is not.

For a detailed explanation, see
http://www.cs.tut.fi/~jkorpela/html/empty.html
It seems that the Validator has changed its behaviour since 2004.


Not in this respect; the report about its behaviour was just vague.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 24 '05 #2

P: n/a
th****************@operamail.com wrote:
Is the W3C HTML Validator [1] in error when it returns <br /> as valid
for HTML 4.01 Strict doctype?
No. It's valid. In HTML <br/> is short for <br>> (whereas in XHTML it
is short for <br></br>). Fortunately (from the point of view of XHTML
bacwards compatability) virtually no browser gets HTML right so it's
treated as <br>.
In March 2004 [2], the Validator returned <br />, <hr /> and <img />
as invalid for HTML 4.01 Strict.
Depends where you use them. As they are equivalent to <br>>, <hr>> and
<img>> you can not use them where text (i.e. the >) would be invalid
(though that would also rule out <img>).
Liam Quinn said [2] "You can't mix HTML and XHTML. You need to choose
one or the other syntax."
[meaning: choose <br> for HTML and <br /> for XHTML]
Good, and correct, advice.
As for today, the Validator returns <br /> and <img /> as valid for
HTML 4.01 Strict, but <hr /> (and also <meta /> and <link />)
as invalid.
Presumably you're using <br /> an <img /> in places where text is
allowed and hence the > is valid. But the <hr/> is in a place where
text is not allowed and hence then > is an error. As <meta> and <link>
can only go in the head, where text is not allowed you must use the
HTML form.
It seems that the Validator has changed its behaviour since 2004.


Have you asked the W3C Validator team?

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 24 '05 #3

P: n/a
th****************@operamail.com wrote:
In March 2004 [2], the Validator returned <br />, <hr /> and <img />
as invalid for HTML 4.01 Strict.

Liam Quinn said [2] "You can't mix HTML and XHTML. You need to choose
one or the other syntax."
[meaning: choose <br> for HTML and <br /> for XHTML]

As for today, the Validator returns <br /> and <img /> as valid for
HTML 4.01 Strict, but <hr /> (and also <meta /> and <link />)
as invalid.

It seems that the Validator has changed its behaviour since 2004.


In HTML 4.01, <br /> is equivalent to <br>>. It's not invalid, just
different from what you mean. <meta /> and <link /> are invalid because
the second greater-than sign ends the HEAD section (any character data
would), and you presumably haven't completed it yet. <hr /> is invalid
because while block-level content (the HR element itself) is allowed as
a direct child of the BODY element in Strict, character data (the
greater-than sign) isn't.

I'm not sure why the results were different when you previously tried.
Are you sure it was the same document?
Jul 24 '05 #4

P: n/a
th****************@operamail.com wrote:

Liam Quinn said [2] "You can't mix HTML and XHTML. You need to choose
one or the other syntax."
Yep.
[meaning: choose <br> for HTML and <br /> for XHTML]
Yep. But that's not what it looks like.
As for today, the Validator returns <br /> and <img /> as valid for
HTML 4.01 Strict, but <hr /> (and also <meta /> and <link />)
as invalid.


Nope. It depends entirely on context whether any of those are
technically valid. But if they are, they are valid for the wrong
reason (some of us call it a bug in the HTML spec) and don't
mean what you think.

See http://valet.webthing.com/page/parsemode.html

--
Nick Kew
Jul 24 '05 #5

P: n/a
Hello Yucca,

Thanks for replying.

The discussion seems to concern two issues:

1. Changed behaviour of W3C Validator
2. <br /> conforming to HTML 4.01 Specification

1.
I don't agree with you that I have misunderstood the thread at
ww***********@w3.org [1].

Because, the teacher that checked (in March 2004) his HTML 4.01 Strict
document got <br /> and <img /> as invalid by the Validator.

So, that would mean that the Validator has changed its behaviour since
March 2004, as it nowadays returns <br /> as valid for an HTML 4.01
Strict document.

Now, although I have written W3C/WAI valid docuemnts
(non-professionally) since 1999(?) - and read the W3C technical reports
- I have failed to notice (in the 4.01 Spec.) that <br /> is valid HTML
4.01 Strict, because during the years from XHTML Spec. <br /> was not
valid 4.01, if I remember correctly. Therefore, I have, until now,
regarded <br /> as unique for XHTML documents.

So, it seems that they have updated the Validator, as they do from time
to time.
2.
I am too tired to continue. I will finnish tomorrow.

Thanks also to Steve and Leif for replying. (I just saw your messages.)

Regards,
Thomas Jedenfelt

[1]
http://lists.w3.org/Archives/Public/...r/2003Mar/0028

Jul 24 '05 #6

P: n/a
Thomas Jedenfelt wrote:
1. Changed behaviour of W3C Validator
2. <br /> conforming to HTML 4.01 Specification

Because, the teacher that checked (in March 2004) his HTML 4.01 Strict
I think you mean 2003.
document got <br /> and <img /> as invalid by the Validator. So, that would mean that the Validator has changed its behaviour since
March 2004, as it nowadays returns <br /> as valid for an HTML 4.01
Strict document.
Since they didn't provide an example document demonstrating the issue, it is
difficult to try to reproduce it. I suppose the public CVS archives might
go back far enough that its possible to retrieve it, but that's rather too
much effort for me to worry about right now.

Either:

1. There was a bug in the validator in early 2003 that has now been fixed

or

2. The author of that email was finding that <hr /> was invalid and
*assuming* that <img /> and <br /> were too.

I'd suspect option 2 myself.
Now, although I have written W3C/WAI valid docuemnts
(non-professionally) since 1999(?) - and read the W3C technical reports
- I have failed to notice (in the 4.01 Spec.) that <br /> is valid HTML
4.01 Strict


The spec doesn't say that it is valid, nor does it say that its invalid. Its
obscure stuff that you generally don't find out unless you read the SGML
spec or someone else explains it to you.
--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 24 '05 #7

P: n/a
David Dorward wrote:
2. The author of that email was finding that <hr /> was invalid and
*assuming* that <img /> and <br /> were too.

I'd suspect option 2 myself.


I wouldn't.

I expect the reason for the difference was context.
Technically speaking, <hr/> & friends are valid where
bare text is allowed. Your example now had them inside
a <p> or <div> or somesuch, whereas in the 2003 example
they were not in a valid context.

--
Nick Kew
Jul 24 '05 #8

P: n/a
On Thu, 21 Apr 2005 20:54:18 +0100, Nick Kew <ni**@asgard.webthing.com>
wrote:
th****************@operamail.com wrote:
Liam Quinn said [2] "You can't mix HTML and XHTML. You need to choose
one or the other syntax." Yep.
That part holds true so far...
[meaning: choose <br> for HTML and <br /> for XHTML]
It seems to me that most people that gets into to this kind of
discussion does not have a first clue of what's at stake.
Yep. But that's not what it looks like.
As it has been repeated in this NG for years now...
As for today, the Validator returns <br /> and <img /> as valid for
HTML 4.01 Strict, but <hr /> (and also <meta /> and <link />)
as invalid.


Why do you think that there has to be a whitespace before NESTC+NET?

Has it ever occured to you that it may be an afterconstruct, designed to
use available browsers bugs to get through?
Nope. It depends entirely on context whether any of those are
technically valid...


--
Rex

Jul 24 '05 #9

P: n/a
Hello all,

Thanks for the input.

Let's see if I can summarize:

1. THE VALIDATOR's BEHAVIOUR
2. <br /> CONFORMING TO 4.01 SPEC.
3. HOW TO CHOOSE CODE
1. THE VALIDATOR's BEHAVIOUR

We don't know how teacher's document was coded, or the behaviour of the
Validator in March 2004.

So, that the teacher found his document invalid, may be due to wrong
coding and/or that the Validator may have wrongly interpreted the 4.01
Spec.

Let us just leave the discussion for this topic, as we cannot capture
what has gone before.

Currently (April 2005), the Validator validates <br /> and <img />, but
not <hr />, as HTML 4.01 Strict.

News for the W3C Markup Validator
http://validator.w3.org/whatsnew.html
2. <br /> CONFORMING TO 4.01 SPEC.

May be valid HTML 4.01
<br />, <br>>, <img />
An element (not the tags <>) may be followed by
character data (<br z>).

May not be valid HTML 4.01
<hr />, <hr>>, <meta />, <link />

HTML 4.01 Spec. and SGML Spec. may be interpreted differently by people
(Spec. authors, Web page authors, the Validator Team), and HTML 4.01
Spec. also has errors.
http://www.w3.org/MarkUp/html4-updates/errata

HTML 4.01 Spec.: On SGML and HTML
http://www.w3.org/TR/html401/intro/sgmltut.html

SGML Source Home Page (by the SGML inventor himself)
http://www.sgmlsource.com/
3. HOW TO CHOOSE CODE

Following Liam Quinn's advice, I will use <> for HTML 4.01 Strict and
</> for XHTML, as I have done before.
Finally.
It would be nice if you could post links to W3C documents regarding the
above. And, links to people who has written comments on this topic.

(Thanks to Yucca for his link.)

Regards,
Thomas Jedenfelt

Jul 24 '05 #10

P: n/a
Nick Kew wrote:
David Dorward wrote:
2. The author of that email was finding that <hr /> was invalid and
*assuming* that <img /> and <br /> were too. I'd suspect option 2 myself.

I wouldn't. I expect the reason for the difference was context.
Technically speaking, <hr/> & friends are valid where
bare text is allowed. Your example
I didn't give an example.
now had them inside a <p> or <div> or somesuch, whereas in the 2003
example they were not in a valid context.


That was my point, sorry if I didn't phrase it well. <hr> is often used
where bare text is not allowed while <img> and <br> can only be used where
bare text is allowed. So <hr /> would be invalid as the ">" bare text isn't
allowed there, but <img /> and <br /> pass the test.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 24 '05 #11

P: n/a
Thomas Jedenfelt wrote:
Currently (April 2005), the Validator validates <br /> and <img />, but
not <hr />, as HTML 4.01 Strict.
Maybe, maybe not. It depends where you use it.

http://dorward.me.uk/tmp/the-slash-issue.html
May not be valid HTML 4.01
<hr />, <hr>>, <meta />, <link />
All of those may be valid. <hr> is allowed in some places where character
data is allowed. The end tag of <head> and start tag of <body> are
optional, so if <meta /> or <link /> is the *last* element of the <head>
and the <body> and </head> tags are left out, then its valid. (<link />
becomes <link></head><body>&gt;)

Of course "valid" doesn't mean "good".
Following Liam Quinn's advice, I will use <> for HTML 4.01 Strict and
</> for XHTML, as I have done before.


Yes

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 24 '05 #12

P: n/a
"Thomas Jedenfelt" <th****************@operamail.com> writes:
Hello Yucca,

Thanks for replying.

The discussion seems to concern two issues:
Quite.

1. Inverting Korpela's 22nd law doesn't work.
2. Neither does ignoring the 3rd.
I will finnish tomorrow.


That's highly unlikely.

Yucca will be finnish tomorrow for sure, you on the other hand will
provide a minimal testcase.
A minimal testcase would approximately look like this:

<http://validator.w3.org/check?uri=http://sandbox.bednarz.nl/.swap/gimmeabr.html&ss=1&sp=1>
(DUH! :)
--
| ) Pi├╣ Cabernet,
-( meno Internet.
| ) http://bednarz.nl/
Jul 24 '05 #13

This discussion thread is closed

Replies have been disabled for this discussion.