0

I have the following code:

<table>
 <thead>
    <th class='1'>Date</th>
    <th class='2'>Start Time</th>
    <th class='3'>End Time </th>
    <th class='4'>Location</th>
</thead>
  <tbody>
    <td class='1'>Date</td>
    <td class='2'>Start Time</td>
    <td class='3'>End Time </td>
    <td class='4'>Location</td>
</tbody>
</table>​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

and the css

 table {width:550px;}
​.1 {width:60px; background-color:green;}
.2 {width:90px; background-color:blue;}
.3 {width:90px; background-color:red;}
.4 {width:100px; background-color:yellow;}​

Why can't I set the width? The background color isn't changing either so I must have a code error.

user1015214
  • 2,733
  • 10
  • 36
  • 66
  • 2
    Try class names that start with a letter instead of a digit. – Šime Vidas Jul 23 '12 at 18:27
  • You cannot have class names starting with a digit, see http://stackoverflow.com/questions/448981/what-characters-are-valid-in-css-class-names – Tom Walters Jul 23 '12 at 18:27
  • A small follow up question: if I now would make the with of class=1 (which I now changed to 'a') to 30, which of the columns now gets the rest of the width. Does it get divied up or does it all go to the last one? – user1015214 Jul 23 '12 at 18:31

1 Answers1

2

Class names cannot start with digits. Try renaming your classes to begin a letter (a-z).

JS Fiddle: http://jsfiddle.net/sDKp2/

JSW189
  • 6,267
  • 11
  • 44
  • 72
  • More exactly, a class selector in CSS must not contain a class name starting with a digit. As per HTML specs, such class names are allowed (and could be used in scripting). They could even be used in conjunction with CSS, but then you need to use an attribute selector like `[class='1']` instead of class selectors like `.1` (and attribute selectors are still a little less widely supported than class selectors). – Jukka K. Korpela Jul 23 '12 at 18:39