Re: Seeking clarification of CSS2 section 6.1.1

[Mon, 1 Apr 2002 07:43:07 -0500] Art.Barstow@nokia.com:
>In section 6.1.1 of the CSS2 spec, item #2 says:
>
>[[
>2. Otherwise, if the property is inherited, use the value of the 
> parent element, generally the computed value
>]]
>
>Does "inherited" in this context mean:
>
>1. the property was defined with Inherited:yes [only]
>2. the property's value is 'inherit' [only]
>3. 1 or 2  [the 'and' case seems unlikely]
>4. something else?

If we restore the context:

|| 6.1.1 Specified values
|| 
|| User agents must first assign a specified value to a property based on
||  the following mechanisms (in order of precedence):
|| 
|| 1. If the cascade results in a value, use it. 
|| 2. Otherwise, if the property is inherited, use the value of the parent
||    element, generally the computed value. 
|| 3. Otherwise use the property's initial value. The initial value of
||    each property is indicated in the property's definition.
|| 
|| Since it has no parent, the root of the document tree cannot use values
|| from the parent element; in this case, the initial value is used if
|| necessary. 

we can see that rule 2 applies only to your "case 1" --- otherwise, item 1
applies (if the property is inherited) or item 3 applies (if it isn't).

However, your case 2 is explicitly covered by 6.1.1 rule 1 combined with
section 6.2.1:

|| 6.2.1 The 'inherit' value
|| 
|| Each property may also have a specified value of 'inherit', which means
|| that, for a given element, the property takes the same computed value
|| as the property for the element's parent. The inherited value, which is
|| normally only used as a fallback value, can be strengthened by setting
|| 'inherit' explicitly. 

which appears intended to specify the same behavior.


I say "appears" because of one small difference... I don't know if it's
intentional or accidental.  Section 6.1.1 rule 2, regarding default
inheritance, says "generally the computed value" is inherited; while
section 6.2.1, regarding explicitly specified inheritance, says "the
property takes the same computed value" as the parent.

Consider the "line-height" property as defined in CSS2 section 10.8
<http://www.w3.org/TR/REC-CSS2/visudet.html#line-height>.  The
property is inherited; but when the value of the property is a number,
the specification states:

|| <number>
|| The computed value of the property is this number multiplied by the
|| element's font size. Negative values are illegal. However, the number, not
|| the computed value, is inherited. 

which, together with section 6.1.1 rule 2, tells us that when the cascade
yields no specified value for the line-height property, if on the nearest
ancestor for which a value was specified it was specified as a number, the
numeric value (not the computed value) is inherited.

(I *think* "line-height: normal" is meant to be inherited as "normal," not
any specific length or number; but the wording about that is not entirely
clear.  It *could* be read as saying whatever particular "number" the user
agent assigns as "normal" for an element must be inherited by its children
in the absence of a new specification for the property.  That is not the
same as saying "normal" is inherited: a user agent might pick different
multipliers for different fonts --- e.g., the "external leading" defined
within a font might be used to determine "normal" leading in Windows.)

So... is section 6.2.1 telling us that when "line-height: inherit" is
explicitly specified, the *computed* value is inherited, even if the parent
specified, say, "line-height: 1.6" (or "line-height: normal")?  Are there
two kinds of inheritance, with different rules for "default inheritance"
and "explicit inheritance"?  Or is the wording of 6.2.1 a mistake?


>When I load the CSS/HTML code below, some browsers seem to have 
>implemented interpretation #1 above and other browsers seem to have
>implemented interpretation #2.

Well... in both browsers I have handy (Opera 6 and IE 6), the document
fails to render at all as expected when saved with an XML extension (so
that it is processed as an XHTML document).  When saved with an HTM
extension (and thus processed as an HTML document), both browsers fail to
process the "border-style: inherit" rule as expected.  (This persists if it
is split into "border-left-style: inherit" and so forth.)

Opera is known to have problems with explicit inherit as well as with
borders.  A test will reveal that if the "ul" rule is removed, the display
shifts a bit: Opera is leaving space for the border, even though it doesn't
draw it.  (You can confirm just what is happening by adding backgrounds to
show the spacing of items more clearly.  Opera is leaving space for the
border when "border-style: inherit" is specified; but it won't actually
draw it unless "border-style: double" is coded.)

By adding another style rule we can get a little more insight.  Consider:

     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
     "http://www.w3.org/TR/html4/loose.dtd">
     <html><head>
     <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
     <title>CSS test ...</title>
     <style type="text/css">
        *    { border-style: dotted }
        body { border-style: double }
        ul   { border-style: inherit}
     </style></head><body>
      <ul>
       <li>First ... </li>
       <li>Second ...</li>
      </ul>
     </body></html>

(your example changed to pure HTML 4.01 Transitional with a border-style
rule for all elements added).

Opera, again, leaves space for a border around the ul; but a border
(dotted) is drawn only if the ul rule is removed.  In IE 6, a dotted border
is drawn around the ul element regardless of whether the ul rule is
present: it appears that IE 6 simply doesn't recognize the "inherit"
keyword on border-style at all.

Both these browsers seem to be buggy in ways relevant to your example;
so I see no reason to credit them as examples of what should happen.  As I
read the standard, the ul should have a double-line border.
-- 
Randall Joseph Fellmy aka Randy@Coises.com

Received on Monday, 1 April 2002 17:12:36 UTC