What is this CSS definition?

T

Tami Fischer

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?
 
J

Jukka K. Korpela

David Håsäther said:
What in the world does "a[....]" mean?
Is that standard with CSS?

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

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top