Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS select a class containing plus sign "+"

How can I select an element by class name containing a plus sign +?

E.g.

.frme_150+1 {background-position: 150px 1px;}

The plus value is changed by using JavaScript, is this possible to use + character in selector name?

like image 367
Sam Avatar asked Jan 27 '14 10:01

Sam


1 Answers

You'd need to escape the plus sign as it has a special meaning in CSS, by using a leading backslash \ as follows:

.frme_150\+1 {
    background-position: 150px 1px;
}

Working Demo.

Or escape the '+' to '\2b ' or '\00002b' (six hexadecimal digits)

Also, you can achieve this by using CSS Attribute Selector:

[class="frme_150+1"] { background-position:150px 1px; }

Working Demo.

like image 64
Hashem Qolami Avatar answered Sep 16 '22 20:09

Hashem Qolami