Hector Barbossa
Hector Barbossa

Reputation: 5528

Select all but one td in a table using CSS

I’m looking for a way to style everything except some. If I wanted to select everything within a table except a particular td how to achieve this using css only ?

Upvotes: 0

Views: 691

Answers (3)

Rajat Saxena
Rajat Saxena

Reputation: 3915

There's also a :not() pseudo class in CSS3 which does similar thing.Here is the working demo too http://jsfiddle.net/raynesax/Ps48t/1/

Upvotes: 1

sandeep
sandeep

Reputation: 92803

there are several way to do that. For example

give common property

table tr td{background:red}

for particular element

table tr td:nth-child(3){background:green};

there other :last-child, :first-child

Upvotes: 1

kovshenin
kovshenin

Reputation: 32602

If your particular td has a class name then:

table td { background: red; }
table td.particular { background: white; } /* inherit, auto, etc */

Upvotes: 4

Related Questions