Getting only one column in a table to word wrap.

I'm playing with HTML and have tables with a number of columns.  If the div they are in isn't wide enough then the contents in the columns will break and wrap.  However I'd like only one column to break and wrap with all of the others staying fixed no matter what is in them.

Is there an easy way to accomplish this?  I could specify the column widths (as a percentage or specify a fixed width) for those I don't want to break but that seems like work.  Is there an easier method?
LVL 50
dbruntonQuid, Me Anxius Sum?Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shaun VermaakTechnical Specialist/DeveloperCommented:
Can you post as a JSFiddle?
https://jsfiddle.net
0
Terry WoodsIT GuruCommented:
You mean something like this?

http://jsfiddle.net/7usnjq5x/2/

I've configured the outer container so that you can use your mouse to adjust the size and see what happens. This is an example originally from https://stackoverflow.com/questions/3568262/css-columns-fixed-width-and-remainder that I've modified to better demonstrate the principle.
0
Chris StanyonWebDevCommented:
You can use the css white-space rule to prevent text from wrapping. The following will prevent wrapping on all but the first column:

td { white-space: nowrap; }
td:nth-child(1) { white-space: normal; }

Open in new window

0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

dbruntonQuid, Me Anxius Sum?Author Commented:
Give us about six hours to work out if I can use JSFiddle.  Looks semi-interesting.

At present a code sample is here  http://jsfiddle.net/10kqxtfj/5/

The Spare Part column is the one I want to wrap.  All others I want to stay still.  The width here is 300 px for showing the wrapping.  It is normally about 700 px.
0
dbruntonQuid, Me Anxius Sum?Author Commented:
Hmm.

@Chris Stanyon - that looks interesting ...
0
Chris StanyonWebDevCommented:
For the Spare Part column to wrap while all others don't, you'd just need this:

td { white-space: nowrap; }
td:nth-child(4) { white-space: normal; }

Have a look at the updated fiddle: http://jsfiddle.net/ChrisStanyon/10kqxtfj/8/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dbruntonQuid, Me Anxius Sum?Author Commented:
Thanks everyone.

Chris's code did it.  I've got a little bit more experimenting to do as there are some <th> which might need to be smacked as well.

JSFiddle is interesting.  Thanks Shaun.

And Terry that code is scaring me.  I'm not that advanced in HTML and CSS but thanks for the time in putting it up.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.