W3C home > Mailing lists > Public > www-validator@w3.org > January 2015

Re: [VE][html5] Confusing error message with div inside p

From: Jukka K. Korpela <jkorpela@cs.tut.fi>
Date: Sun, 04 Jan 2015 13:04:34 +0200
Message-ID: <54A91E42.1020004@cs.tut.fi>
To: Jona Moß <jona.moss@web.de>, www-validator@w3.org
2015-01-04, 1:18, Jona Moß wrote:

> when you validate this code:
>
>     <p>
>        <div>foo</div>
>     </p>
>
>
> You will get the following error message: " No p element in scope but a
> p end tag seen."

That’s as adequate as I can imagine, given the constraint that the 
message needs to be reasonably short.

> I find this message very confusing as there /is/ a p element in scope.

No, the p element started with <p> was implicitly terminated by the 
<div> tag, by HTML rules.

> A less confusing message could be "invalid div element inside p element".

I think that would actually be confusing—and wrong. There is no div 
element inside a p element. There is a p element followed by a div 
element followed by a homeless end tag </p>.

I suppose it would be possible to issue an additional diagnostic that 
says something like “(Possibly an attempt at using a div element inside 
a p element.)” Would I also suppose it would be far from trivial to do 
so, and I’m afraid it wouldn’t help much. Diagnostics based on guesses 
of what seems to be the cause are too often misguided and misguiding. 
Even when the guess is wrong, the user would probably say “What? Of 
course it is! What on &Earth; is wrong with that??”

Somewhat related to this, in the example case, the p element contains 
nothing but whitespace characters. Such an element, like a completely 
empty p element, is often caused by a mistake in HTML coding like here. 
The good old HTML 4.01 specification informally said that authors should 
not use empty p elements and that browsers should ignore such elements 
(this did not happen). HTML5 has no such statement, but it has a much 
wider statement:

“As a general rule, elements whose content model allows any flow content 
or phrasing content should have at least one node in its contents that 
is palpable content and that does not have the hidden attribute specified.”
http://www.w3.org/TR/html5/dom.html#palpable-content-0

It then explains why this is not a “hard requirement”. But I wonder 
whether it would be useful to issue either a warning or an informative 
message about such situations, like a p element with no palpable 
content. HTML5 even says: “Conformance checkers are encouraged to 
provide a mechanism for authors to find elements that fail to fulfill 
this requirement, as an authoring aid.”

Such checks would detect many situations where the intended markup 
structure is different from the meaning of the markup actually used, in 
addition to many other problems. In a case like this, there would still 
be an error message that the user may find difficult to understand, but 
at least there would be another message before it, possibly pointing to 
the right direction. (I’m afraid “p element with no palpable content” 
would be cryptic to most people, but perhaps a better wording could be 
written.)

Yucca
Received on Sunday, 4 January 2015 11:05:04 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 1 March 2016 14:18:12 UTC