What is this CSS definition?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hello there,

a[href ^="http:"] {
        background-color: lightgreen;

a[href ^="http:"]:hover {
       background-color: red;

a[href ^="http://brahbrah"] {
       background-image: none;
       background-color: trasparent;

What in the world  does "a[....]" mean?
Is that standard with CSS?

T. Fischer

Re: What is this CSS definition?

Quoted text here. Click to load it


Quoted text here. Click to load it

It's an attribute selector, see <http://www.w3.org/TR/2001/CR-css3 -

David Hsther

Re: What is this CSS definition?

Quoted text here. Click to load it

So in this case, a[href ^="http:"] is a selector that matches those <a>
elements that have an href attribute and that attribute's value begins
with the string "http:".

And it is not standard CSS - it does not belong to the CSS 2.0
specification or the CSS 2.1 draft, and CSS 3.0 is just a collection of
various sketches. Note that the CSS 3.0 Selectors draft is titled
"W3C Candidate Recommendation 13 November 2001", with text saying:
"This is still a draft document and may be updated, replaced, or
obsoleted by other documents at any time. It is inappropriate to cite a
W3C Candidate Recommendation as other than "work in progress.""

Actually that draft also says:
"The duration of Candidate Recommendation is expected to last
approximately six months (ending May, 2002)."
(If I remember the W3C policies and process documents correctly, the
draft should actually have been moved down to a lower - less mature -
level long ago, since it did not progress to a Proposed Recommendation.)

Moreover, even the simpler attribute selectors as defined in CSS 2
have very poor support - IE doesn't get them at all. That's why pragmatic
authors use lots of classes instead.

Yucca, http://www.cs.tut.fi/~jkorpela /
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Site Timeline