> > > From: Peter Weil
> > >
> > > Does the selector:
> > >
> > > body#about-us.level2
> > >
> > > combine the body ID "about-us" and  and the body class "level2"?

> > From: Michael Geary
> > Yes. It matches the body element if that element has both the 
> > specified ID and class.

> >> If so, where is this technique documented?

> > http://www.w3.org/TR/CSS21/selector.html#selector-syntax 

> Thanks Mike. To be honest, I'm still not completely convinced 
> that this is what the W3C documentation actually says (I did 
> try reading it several times before I gave up), and no 
> examples are given. I don't necessarily doubt that you are 
> right, but can you point me to any other references to this 
> type of selector? I can't find any mention of this anywhere 
> else.  Does anyone else use this technique, or know of any 
> examples cited in articles, books, blogs, etc.?

(I meant to cc the list on my previous reply, adding it back now...)

If you think the W3C specifications can be a bit hard to follow, try the 
ECMAScript standard sometime! It gives me a sore brain
every time I look at it.

Anyway, now that you mention it, I was reading between the lines just a little. 
Here's what the section I cited says:

"A simple selector is either a type selector or universal selector followed 
immediately by zero or more attribute selectors, ID
selectors, or pseudo-classes, in any order. The simple selector matches if all 
of its components match."

.level2 is a "class selector" as defined in the list of selector types in that 
same page, and the text doesn't mention class
selectors at all. But it does mention attribute selectors, one of which is 
[attribute~="value"]. So, this would be a valid "simple
selector" according to the text:

body#about-us[class~="level2"]

Since .level2 is synonymous with [class~="level2"], it's not too much of 
stretch to think that you can substitute one for the other:

body#about-us.level2

Even if I'm interpreting this correctly, it leaves open the question of which 
browsers do or don't support it, which is all that
really matters in the end.

I have had trouble with a similar selector that I really wanted to use:

.class1.class2 {...}

This would match an element such as <div class="class2 class1"></div>. When I 
tried to use it a year or so ago in a day picker
calendar widget, I seem to recall that it didn't work at all in IE, and I had 
to resort to extra nested elements to allow this kind
of "and" condition.

Calendars are where this kind of selector could be really handy - you want to 
be able to style weekdays vs. weekends, and you want
to be able to style days in the current month vs. days in the partial months at 
the beginning and end, *and* you want to do
something for the current day, or some selection of days, too. It would be 
great to be able to use a selector like
.weekday.this-month.selected-day.

-Mike

______________________________________________________________________
css-discuss [EMAIL PROTECTED]
http://www.css-discuss.org/mailman/listinfo/css-d
IE7 information -- http://css-discuss.incutio.com/?page=IE7
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/

Reply via email to