Re: Warnings for non-applicable properties

Benjamin Hawkes-Lewis wrote:

> Paul Arzul wrote:
>> CSS defines when properties are applicable (see the Applies column:
>> <http://www.w3.org/TR/CSS21/propidx.html>)
>>
>> Should we generate warnings when properties are not applicable? For
>> example: p
>> {
>>     border-collapse : collapse;
>> }
>>
>> We could warn about the paragraph not being a table or inline-table
>> element. (I get no warnings with Warnings set to All.)
>
> That would only be reliable if one could assume default CSS for HTML
> and that p was an HTML element rather than an element in some random
> XML dialect - but you can't assume either from the raw CSS.

Even in that case, the assumptions might fail because the document has
intentionally been written or styled against your expectations.

For example, the <p> element might contain <span class="tr"> elements that
contain <span class="td"> elements, with

p { display: table; }
.tr { display: table-row; }
.td { display: table-cell; }
.td { border: solid 1px; }

and then setting p { border-collapse : collapse; } surely has an effect (on
supporting browsers). You might issue a warning about this not being
intended use of markup or styling, but what exactly would you say? You must
_not_ claim that border-collapse does not apply; it surely does, when the
display property is set to table.

Logically, you could issue a warning about a declaration like
p { display: table; }
if you think that the essentials of the presentation of an element should
not be changed in CSS. But where would this end? Would it be OK to change a
list to a horizontal row of boxes? To set display: none?

And if you don't issue such warnings, then you can't really warn about p {
border-collapse : collapse; } on the grounds that the property does not
apply to a "paragraph".

But you _could_ issue warnings that are solely based on applicability
statements made within CSS specs. For example, you could check whether the
display property has the value table and if not, issue a non-applicability
warning about border-collapse. Of course this means that you would need to
include some assumed default browser style sheet, so that you know (or think
you know) the default values for the display property of different elements,
for example.

Besides, you cannot really know the properties of an element by analyzing
one style sheet only, even if you assume that the document is HTML. Any
other style sheet (that will be used when rendering the document, along with
the style sheet being analyzed) might assign display: table, making
border-collapse applicable.

> The validator could include additional UI (e.g. checkboxes to indicate
> that this CSS if for HTML and the valiator should assume the suggested
> default CSS from CSS 2.1) that would mitigate those problems.

I have no specific objections, but who is going to define what is and what
is not applicable to different elements then?

-- 
Yucca, http://www.cs.tut.fi/~jkorpela/

Received on Sunday, 9 November 2008 18:57:38 UTC