Re: [VE][64] Nesting of Option and Span

David Spector wrote:

> W3C Validation Service,

The www-validator list is a public discussion list, where you might get 
comments from anyone, not just W3C staff.

> 1. I don't understand what is causing this error in my
> HTML and I don't know how to fix it.

The error is caused by improper improper nesting of elements, 
specifically by using a span element inside an option element, where 
_no_ element is allowed, just text. How to fix it is a many-faced 
question and not directly a validation matter: a validator just tells 
whether some markup is allowed or not, not how it could or should be 
modified to achieve the same effect (though we discuss such matters in 
this list to some extent - but mostly they belong to different forums on 
HTML and CSS authoring etc.).

> 2. The error message (see below) shown on page
> http://validator.w3.org/check is not helpful. Can you
> improve it?
>
> Details:

Fine. As a rule, posting the URL of a document that demonstrates the 
problem is preferred, but in this case, the information provided 
(fragments of code) happen to be sufficient.

> "Line 89, Column 40: document type does not allow
> element 'SPAN' here." (error 64)

I'm not sure how this could be improved, unless the whole internal 
structure of the validator is rewritten. As far as I have understood, it 
currently does not "know" the wider context when reporting a syntax 
error, such as being inside an option element, so it cannot use a more 
specific expression (like "inside an 'OPTION' element") instead of 
"here".

Did you read the fint print after the error message? Maybe it shouldn't 
be fine print. After all, on web pages, fine print is typically the 
symptom of designitis ("designers" imitating "artistic" printed matter) 
or legalese, i.e. text included to please lawyers and not read by 
anyone. Surely it can here be increased by setting the browser's font 
size, but what if the user _has_ set the font size to something that 
produces a copy text size suitable for him?

Anyway, the fine print says (in the first paragraph; the second one is 
irrelevant here):

"The element named above was found in a context where it is not allowed. 
This could mean that you have incorrectly nested elements -- such as a 
"style" element in the "body" section instead of inside "head" -- or two 
elements that overlap (which is not allowed). "

Well, this is a case where you definitely _want_ to put span inside 
option and didn't just accidentally misplace it. The problem is that 
_no_ element may be nested inside an option element.

> Reported erroneous HTML line:
>
> <option value="PayPal" ><span class=nobr>PayPal (pay
> from your bank account or credit card)</span></option>

In principle, there should be no reason for the span markup, since you 
could attach the class directly to the option element:
<option value="PayPal" class="nobr">PayPal (pay
from your bank account or credit card)</option>
However, there might be problems in browsers' implementations of option 
elements, perhaps even problems that manifest themselves so that you 
cannot directly style the contents of such an element but can style an 
inner element, even though this is invalid. Odd things may happen in 
Browserland.

> Doctype:
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
> Transitional//EN">

For the purposes of validation, that will work. However, this format 
violates HTML specifications, since it lacks the URL. In practice, it 
throws IE into "quirks" mode, where it intentionally works in odd and 
nonstandard ways; see
http://www.cs.tut.fi/~jkorpela/quirks-mode.html
for a long though incomplete list of quirks.

> What I want to do here is inhibit line wrapping within
> a displayed option value in a Select control.

As I wrote, this is a many-faced question, with a dozen or so different 
approaches, and best discussed perhaps in 
news:comp.infosystems.www.authoring.misc.

You might consider what was the decision that created the problem (the 
need for eventual line wrapping) and whether it is a problem at all - 
for example, IE does not seem to wrap an option text under any 
circumstances. Or you might just remove the parenthetic remark from the 
option text; that specific text is incorrect, since using PayPal does 
_not_ mean paying from a bank account or credit card, it's an 
_alternative_ to them! From a general perspective, this is just a 
reminder of the fact that parenthetic remarks that cause problems in 
authoring (due to attempts to squeeze content into some tiny area) is 
often unnecessary, misleading, or just plain wrong. We now return to our 
validation agenda...

Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/ 

Received on Saturday, 24 November 2007 12:31:48 UTC