1

The following is a class which I use to highlight a row, but it only makes changes for the cursor and font, not bgcolor of a row.

I have also used background-color: #FFDC87; but it fails to get the desired output.

.highlighted {

    bgcolor: #FFDC87;
    cursor          : pointer;
    /*font-size : 50px;*/
}

How can I make it work?

4 Answers 4

11

That's because the bgcolor CSS property doesn't exist. The property you're looking for is background-color.

If this doesn't work, there's something else that is messing with the element's background-color, and is blocking this from working. But we'll need a little more code to help you with that.

Sign up to request clarification or add additional context in comments.

2 Comments

There's always !important to save the day. w3.org/TR/CSS2/cascade.html#important-rules
No offense, but the OP missed the obvious bgcolor... IMO he shouldn't be exposed to !important just yet.
5

As is clear by the other answers, it's background-color instead of bgcolor. Note that you can see if there are errors in your HTML, JS or CSS code if you're using a plug-in like Firebug or Webdeveloper (both Firefox plug-ins). This is what Webdeveloper mentioned:

alt text http://img191.imageshack.us/img191/7469/csserror.png

And you'll probably also want to make the table's borders collapse, otherwise the rows in your table will have gaps in it. Here's what you could do:

<html>
  <head>
    <style>
      table {
        border-collapse: collapse;
      }
      td {
        padding-right: 10px;
      }
      .highlighted {
        background-color: #ffdc87;
        cursor: pointer;
      }
    </style>
  </head>
  <body>
    <table>
      <tr class="highlighted">
        <td>1</td><td>11</td><td>111</td>
      </tr>
      <tr>
        <td>2</td><td>22</td><td>222</td>
      </tr>
      <tr class="highlighted">
        <td>3</td><td>33</td><td>333</td>
      </tr>
      <tr>
        <td>4</td><td>44</td><td>444</td>
      </tr>
      <tr class="highlighted">
        <td>5</td><td>55</td><td>555</td>
      </tr>
    </table>
  </body>
</html>

Comments

3

Instead of bgcolor, the CSS rule is background-color. Give that a try.

Comments

2

The CSS for background color is "background-color", e.g. background-color: #FFDC87;

Try that :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.