Alex Rivera | Logout

Is it possible to use css wildcard class selector where there are multiple class values?

Asked 2013-06-05T15:05:19.857
11

Is there a CSS selector where i can select all anchors with a class containing icon-*

<a class="icon-a icon-large scrollTo" href="#a"></a>
<a class="icon-large icon-b scrollTo" href="#b"></a>
<a class="icon-large scrollTo icon-c" href="#c"></a>

I just jumbled up the icon- since i want to check if the css selector can handle all cases.

I want to be able to change the style of all anchors that contains the class icon-*. This code doesn't seem to work.

a [class^="icon-"], a [class*=" icon-"] {
    text-decoration: none;
    color: #1BA1E2;
}

Is Javascript my only option?

Edit
Report

1 Answer

5

Yes - but you first need to remove the space between the type selector and the attribute selector and the space in the attribute value:

a[class^="icon-"], a[class*="icon-"] {
text-decoration: none;
color: pink; /* get rid of the # */
}

http://jsfiddle.net/c8YdD/1/

answered 2013-06-05T15:07:56.713

Your Answer