1

Now I know classes can't start with numbers but here's the situation. This Wordpress theme has 5 columns, all 5 have a class of span3, mbtm and feature, but then they also have classes of first, 0.25, 0.5, 0.75 and last.

I only want to add a different background colour to the middle column and the only difference in classes is 0.5 but I can't add CSS properties to .0.5

What is my way around this please?

Adrian
  • 241
  • 2
  • 11
  • have you tried adding a class to the HTML template? – Cubius Apr 05 '14 at 11:09
  • 1
    possible duplicate of [CSS classes with names that start with numbers](http://stackoverflow.com/questions/21227702/css-classes-with-names-that-start-with-numbers) – Jukka K. Korpela Apr 05 '14 at 12:10
  • @JukkaK.Korpela Thank you, so would a class of 0.5, i presume the . is a whitespace character, what would the CSS selector be please, its a bit confusing, thank you. – Adrian Apr 05 '14 at 14:10
  • The period is not whitespace, but since it has a special meaning in CSS, it needs to be escaped when it is part of a class name. For `class=0.5`, a suitable selector is `.\30\.5`. The `\30` is escape for digit zero, and `\.` is escape for the period. – Jukka K. Korpela Apr 05 '14 at 14:37

1 Answers1

1

Check this excellent article by ben frain on the topic: http://benfrain.com/when-and-where-you-can-use-numbers-in-id-and-class-names/

Your css should look like

div[class=0.5] {
    background-color: #0f0; 
}

Although you can escape the characters, imo you should not use it for the sake of readability.

alpipego
  • 3,185
  • 2
  • 15
  • 27