Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

CSS Pre Tag Wrap And Overflow Examples

I built this page to get a better understanding of how CSS properties affect [TODO: Code shorthand span ] tags. There is no css on the page other than what you see listed on the page. Each line in the examples starts with a capitalized word followed by a collection of text and underscores designed to make it easier to see each effect.

I'm using two different versions in production

- When I want wrapping :

css
white-space: pre-wrap; 
overflow-wrap: break-word;
css
white-space: pre; 
overflow-x: auto; 
overscroll-behavior-x: none;

- From what I can tell there's not a way to suppress breaking at hyphens without breaking strings at another place. Using [TODO: Code shorthand span ] prevented breaking on the hyphens but broke wherever the string touched the boundary.

- The primary recommendations I found for dealing with hyphens would be to wrap them in spans with nowrap or to change the character to something else that doesn't wrap. (but that would effect copy/paste). So, the wrap seems like the best option if it's important enough to put in the work to make that happen

- An interesting play would be to update a syntax highligher to apply the nowrap along with the rest of the formatting

- I'm not using [TODO: Code shorthand span ] in any of the examples as it' still experimental

- There's also a 'word - break' property but it seems aimed at Chinese/Japanese/Korean (CJK) text. I don't know enough about that to include it here.

Footnotes And References