Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple CSS Classes on a Single Element issue

Tags:

css

I'm using a combination of two classes on a span element.

Both look like they're working by themselves... Together they're not.

.black {color:black;}
.size_14 {font-size:14px;}


<span class="black size_14">my text is not black..neither large</span>

I tried changing the size_14 class name for another one (large) and in this case it is working.

Is size_14 an invalid class name?

SOLVED

I was overriding the behaviour with

.article_text_div .size_14 {color:#6D6E71;}

But thanks to this mistake I discovered It's better(?) not to use underscores inside class names

Double thanks

Luca

like image 501
luca Avatar asked May 06 '11 17:05

luca


2 Answers

That example seems to work fine. There must be another rule that is overriding your change. Check the CSS with Firebug or a similar inspector, it will tell you exactly which classes are being used and overridden.

like image 75
Kaivosukeltaja Avatar answered Oct 21 '22 13:10

Kaivosukeltaja


Underscores are not recommended in class names and ID's. Support is mixed across the board. I would remove it or replace it with a dash.

like image 2
Dustin Laine Avatar answered Oct 21 '22 15:10

Dustin Laine