Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highlight selected row using css

Tags:

html

css

How we can highlight selected row in a table using css. Is there any way to do that?

like image 315
Null Pointer Avatar asked Mar 01 '11 13:03

Null Pointer


People also ask

How do I highlight a selected row in a table?

How do you highlight a row if a cell contains text? Select the cells you want to apply conditional formatting to. Click the first cell in the range, and then drag to the last cell. Click HOME > Conditional Formatting > Highlight Cells Rules > Text that Contains.

How do you highlight a row in HTML?

When you create Web pages in HTML, you can use JavaScript functions to alter the appearance of page elements on user interaction. To highlight certain rows in a table, you can set Cascading Style Sheet declarations for these rows in their normal state and in their highlighted state.

How do you highlight in CSS?

How Do I Highlight Text In CSS? To Highlight text in HTML you have to use an inline element such as the <span> element and apply a specific background style on it. This will create the highlighting effect, which you can tweak in many different ways to create different looks.


3 Answers

Assuming that by "selected" you mean "hovered over by mouse":

tr:hover {background-color: #FF0000}

You could also highlight with things like 'font-weight:bold', 'color: #FF000', etc..

like image 60
Munneson Avatar answered Oct 21 '22 01:10

Munneson


tr { background: sky-blue-pink } /* Use a real colour */
tr * { background: transparent; }

where tr is a more specific selector to indicate whatever condition you have in the DOM to represent 'selected'. This will probably be a class selector: tr.selected

like image 39
Quentin Avatar answered Oct 20 '22 23:10

Quentin


You just have to do something like:

tr:hover { background: #FCF; }

See this example.

like image 30
Trufa Avatar answered Oct 21 '22 01:10

Trufa