Is there a way to request an element with multiple classes in CSS?

How can I request an element that has two classes at the same time?

For example:

<div><span class="major minor">Test</span></div>

I want to create all spans that have “primary” and “secondary” classes at the same time.

+3
source share
2 answers

The following should do the trick:

span.major.minor { color: red; }

Note that you must be careful with this with Internet Explorer 6 - it will only read the last selector class. For example, he incorrectly applies the above rule to the following:

<span class="minor">Test</span>
+6
source

Use the class qualifier twice, for example:

.major.minor { ... }

. IE6 ( IE7 Quirks). , IE . , class="minor".

:

.major-minor { ... }
<span class="major minor major-minor">...</span>

, , , :

.major .minor { ... }
<span class="major"><span class="minor">...</span></span>
+4

Source: https://habr.com/ru/post/1705964/


All Articles