Preventing line breaks in <code> elements
surprisetalk
14 points
20 comments
July 24, 2026
Related Discussions
Found 5 related stories in 63.4ms across 5,804 title embeddings via pgvector HNSW
- HTML Can Do That encyclopedism · 32 pts · August 19, 2026 · 46% similar
- How to Write Unmaintainable Code (2015) theanonymousone · 18 pts · July 17, 2026 · 43% similar
- Small, native web tricks worth remembering marcomezzavilla · 213 pts · August 21, 2026 · 43% similar
- CodePen 2.0 robin_reala · 154 pts · July 30, 2026 · 43% similar
- Write code like a human will maintain it ScottWRobinson · 328 pts · July 10, 2026 · 42% similar
Discussion Highlights (4 comments)
danlitt
You can't parse [X]HTML with regex. Because HTML can't be parsed by regex. Regex is not a tool that can be used to correctly parse HTML.
pwdisswordfishq
Why even bother with the CSS class? Just apply text-wrap: nowrap; to all <code> elements and dispense with the fragile regex parsing.
pimlottc
Unfortunately this makes it much harder to read on narrow-width screens (e.g. mobile), where the use must scroll horizontally
dajtxx
The 5 cm example had a line break between the 5 and the cm when I read the page in my phone. A joke?