Friday, 15 April 2011

Namespacing pseudo-selector by css class -



Namespacing pseudo-selector by css class -

so tried googling find quite hard right search terms in.

i'm trying namespace pseudo-selector on class

in example, without class lastly hi should blue. expect code turn sec span blue, not case. doing wrong or have unreasonable expectation of css should doing?

class="snippet-code-css lang-css prettyprint-override">span.dinosaur:last-child { color: blue; } class="snippet-code-html lang-html prettyprint-override"><body> <span class='dinosaur'>hi</span> <span class='dinosaur'>hi</span> <span>hi</span> <span>hi</span> </body>

i expect code turn sec span blue, not case.

you have fundamental misunderstanding of :last-child pseudo-class; matches if element pseudo-class applied, if element last-child of parent. not equivalent :last-of-type() selector (and that pseudo-class disregards class-names , id, , selects element based on element-type (<div>, <p> etc).

in future, :nth-match() might serve purpose, that's yet implemented (so far i'm aware) in browser, , part of selectors level 4 module.

references:

:last-child. :last-of-type(). :nth-match(). :nth-last-match(). selectors level 4 module.

css

No comments:

Post a Comment