W3C home > Mailing lists > Public > www-style@w3.org > July 2014

Re: CSS3 specificity

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Wed, 23 Jul 2014 08:03:44 -0700
Message-ID: <CAAWBYDAy39wnx=Xgmf52K38B_VQgHOwhVyn8Ws-11X9OyYmQQA@mail.gmail.com>
To: Max Design <info@maxdesign.com.au>
Cc: www-style list <www-style@w3.org>
[Sorry for the delay in responding; our moderation queue was just emptied.]

On Tue, Jun 17, 2014 at 1:28 PM, Max Design <info@maxdesign.com.au> wrote:
> Hi there
>
> I have a question regarding more recent definitions of the cascade process.
>
> In CSS2, specificity was measured with three concatenated numbers: 0,0,0
>
> Apparently, David Barron was the first to suggest a change for CSS2.1
> http://lists.w3.org/Archives/Public/www-style/1999Feb/0001.html
>
> In CSS2.1, specificity was measured using four concatenated numbers: 0,0,0,0
> http://www.w3.org/TR/CSS2/cascade.html
>
> "count 1 if the declaration is from is a 'style' attribute rather than a rule with a selector, 0 otherwise (= a) (In HTML, values of an element's "style" attribute are style sheet rules. These rules have no selectors, so a=1, b=0, c=0, and d=0.)“
>
> In the newer CSS3 specificity model, specificity is again measured using three concatenated numbers: 0,0,0
>
> Referenced here:
> http://www.w3.org/TR/2013/CR-css-cascade-3-20131003/
>
> And defined here
> http://www.w3.org/TR/selectors/#specificity
>
> If I read both documents, there is no reference to inline styles at all. Inline styles are not described under Origin or importance:
>
>         • Transition declarations [CSS3-TRANSITIONS]
>         • Important user agent declarations
>         • Important user declarations
>         • Important override declarations [DOM-LEVEL-2-STYLE]
>         • Important author declarations
>         • Animation declarations [CSS3-ANIMATIONS]
>         • Normal override declarations [DOM-LEVEL-2-STYLE]
>         • Normal author declarations
>         • Normal user declarations
>         • Normal user agent declarations
>
> So, my question... CSS2.1 helped to define how inline styles play out in the cascade order. Am I missing something in CSS3 which defined where inline styles are weighted?

Yup, you're missing something. ^_^

If you look at the bottom of the Specificity section in Selectors,
there's a note about how the specificity of declarations in inline
style attributes is defined by the Style Attributes spec.  Follow that
link, and you'll come to
<http://www.w3.org/TR/css-style-attr/#interpret>, which defines them
as being in the author origin and having a specificity higher than any
selector.

(And btw, you're pointing to the /TR documents, which are rather old,
particularly that Selectors reference from 2011.  Always look at the
Editors’ Drafts instead, at <http://dev.w3.org/csswg/>, as its common
for errors to have already been fixed in the newer version.  Newer
specs always link to their EDs, but older drafts didn't, and I'm sorry
for that.)

~TJ
Received on Wednesday, 23 July 2014 15:04:32 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:23 UTC