Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why the same CSS class twice in a row

Tags:

css

I saw the following line in a code:

.className.className {
   font-weight: bold;
}

Is there a reason to write this twice?

like image 325
Max Pattern Avatar asked Nov 18 '25 17:11

Max Pattern


2 Answers

It is likely used to increase the specificity of the selector.

It would probably be better if it was rewritten to change the source order instead.

like image 54
Quentin Avatar answered Nov 21 '25 07:11

Quentin


Typo maybe. below is valid though.

All <li> elements with a class list that includes both "spacious" and "elegant"

For example, class="elegant retro spacious"

li.spacious.elegant {
  margin: 2em;
}

read more

like image 22
Pasindu Ruwandeniya Avatar answered Nov 21 '25 06:11

Pasindu Ruwandeniya



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!