Yottagray
Yottagray

Reputation: 2592

Restrict Word Wrap on a Specific Table Column With CSS

I'd like to restrict word-wrap on the text in a single column of a table. Basically, I want the equivalent of white-space: nowrap on every cell in the second column of the table.

The thing is, I can't really access the html, only the CSS. So, is there a way to do this with CSS only?

EDIT: It really only needs to work with Chrome or most recent browsers.

Upvotes: 2

Views: 805

Answers (1)

Pekka
Pekka

Reputation: 449415

The nth-child CSS 3 pseudo-class works in Chrome, FF > 3.0, and IE >= 9.

http://jsfiddle.net/TwcEB/

table tr > *:nth-child(2n+1) {
    background-color: red;
}

this is the only non-JavaScript way to do this.

Upvotes: 1

Related Questions