Skip to content

Instantly share code, notes, and snippets.

@prabhuramkumar
Last active June 17, 2020 20:01
Show Gist options
  • Save prabhuramkumar/4491951 to your computer and use it in GitHub Desktop.
Save prabhuramkumar/4491951 to your computer and use it in GitHub Desktop.
CSS trick on word-wrap for table content

Just came across this scenerio... word-wrap on table td's don't work the work around for this is adding a wraper div and then applying word-wrap:break-word on it. But then this is not a semantic solution whichc adds extra divs around content.

Another work around is adding table-layout:fixed on the main table and then addding word-wrap:break-word on td's.

adsfdsafsdfsadfsdafsadfsd table content right

css: table{ table-layout:fixed; } table td{ word-wrap:break-word; width:300px; }

@terrymun
Copy link

@damien-biasotto THIS. I've fiddled around some stylesheets and didn't know white-space: nowrap takes precedence and causes non-breaking behavior.

@dullroar
Copy link

@damien-biasotto THIS +1!!!

@rob-barber
Copy link

@damien-biasotto Thank you! I've been cursing the css gods and their mighty malevolence! This gave me some sanity back finally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment