wolfwings: (Default)
[personal profile] wolfwings
...because I found an incredibly nifty feature of CSS that all this time I hadn't known about, that I'm working to integrate into that web-comic-interface program I was building before: Selectors. It's useful enough I'll deal with posting it here just so everyone on my friends list sees it.

Most folks know about the a:hover CSS-tag that lets you set the 'hover' style for a link, or the div.warning to let you style <div class="warning"> (which is actually a shorthand for something I'm about to show here) but I bet you didn't know about td[direction~="up"] did you? That lets you define new attributes for your elements, for example in this case making this valid: <td direction="up left"> and applying the "up" and "left" styles if you have both defined.

The fairly well-known td.card form (using the class="blah" attribute) is actually nothing more than a shorthand for td[class~="card"] actually. The ~= means that the attribute is treated as a series of space-seperated values, and matches against each one individually. If you replace it with =, as in td[direction="apples and oranges"] then the CSS-style will only apply to that explicit attribute tag, for example if you need to perform some special trickery on some combinations of your custom attributes.

A minimal example of the effect.

(no subject)

Date: 2007-01-27 12:16 pm (UTC)
From: [identity profile] premchai21.livejournal.com

XML Path Language (http://www.w3.org/TR/xpath)

(no subject)

Date: 2007-01-27 05:11 pm (UTC)
From: [identity profile] elfs.livejournal.com
Doesn't work in IE6. In fact, IE6 is notorious about ignoring the [] syntax in CSS declarations.

(no subject)

Date: 2007-01-27 11:12 pm (UTC)
From: (Anonymous)
Not surprised in the least, to be honest.

Appears to work fine in Opera and FireFox 1.5, any chance you know if it works in IE7? Or is that another of the core and highly useful CSS bits they totally screwed up again?

(no subject)

Date: 2007-01-31 09:06 pm (UTC)
From: [identity profile] animecat.livejournal.com
Hey Wolfwings? I've been trying to find you since RCFM... You commissioned a badge from me at RCFM and I never did get any contact info. I've just now found your LJ, and was wondering... what's the next con you'll be at? I'd really like to give you your badge!

Oh cripes!

Date: 2007-01-31 09:57 pm (UTC)
From: [identity profile] wolfwings.livejournal.com
I totally forgot about that in the intervening months between dealing with my grandpa passing away and then helping get ready for FC... and then helping out AT FC. Only not getting my head fully above water again. Gods, thanks for tracking me down. :-)

And the next con I'm guaranteed to be at is FC next year, the next con I plan to attend actually is RCFM. I'm so sorry about totally botching getting you my full contact info before the last RCFM was over though. =-.-=

Re: Oh cripes!

Date: 2007-02-01 03:13 am (UTC)
From: [identity profile] animecat.livejournal.com
Well why don't we plan on meeting at RCFM then? I'm guaranteed to be there. And if you can't make it, I'll see about mailing your badge to you.

Re: Oh cripes!

Date: 2007-02-01 07:43 am (UTC)
From: [identity profile] wolfwings.livejournal.com
Done!

Any chance of seeing a scan or webcam shot of it or something before then? I'm nosy/curious. =^.^=

Style Credit