Last active
September 3, 2019 16:28
-
-
Save dgibson666/ec830ca383801635572dc19234a505e2 to your computer and use it in GitHub Desktop.
CSS: Break Words
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Starting point: https://css-tricks.com/snippets/css/prevent-long-urls-from-breaking-out-of-container/ | |
If this is in a flex-item, make sure that element has a min-width set for IE support | |
(otherwise, IE/Edge will still break words, but infer that the content length is longer than it should be and possibly stretch the container larger than intended) | |
IE/Edge workds nicely with inline elements, until you have another inline element nested within it that needs to wrap/break. | |
IE/Edge's handling of block elements requires "break-all" functionality, which will break words unnecessarily. | |
*/ | |
selector { | |
overflow-wrap: break-word; /* inline elements */ | |
word-wrap: break-word; /* inline elements */ | |
-ms-word-break: break-all; | |
/* This is the dangerous one in WebKit, as it breaks things wherever */ | |
word-break: break-all; | |
/* Override with this non-standard one where supported */ | |
word-break: break-word; | |
/* Adds a hyphen where the word breaks, if supported (No Blink) */ | |
-ms-hyphens: auto; | |
-moz-hyphens: auto; | |
-webkit-hyphens: auto; | |
hyphens: auto; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment