Max Pattern
Max Pattern

Reputation: 1688

Why the same CSS class twice in a row

I saw the following line in a code:

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

Is there a reason to write this twice?

Upvotes: 3

Views: 406

Answers (4)

Quentin
Quentin

Reputation: 943560

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.

Upvotes: 5

André
André

Reputation: 2020

It's a typo!
Technically this code will apply to an element with the following classes: "className" or "className". But because one match is enough and they are the same name it doesn't matter.

Upvotes: 0

Pasindu Ruwandeniya
Pasindu Ruwandeniya

Reputation: 637

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

Upvotes: 1

Finn
Finn

Reputation: 111

Nope. Maybe just typo. It has no meaning on css.

Upvotes: -1

Related Questions