2

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.

2
  • Probably using nth-child but you'll run into browser compatibility issues (namely IE < 9 and FF up to 3). Can you live with that? Commented Apr 1, 2011 at 19:07
  • @Pekka: That would be just fine Commented Apr 1, 2011 at 19:10

1 Answer 1

1

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.

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

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.