Preventing line breaks in <code> elements

surprisetalk 14 points 20 comments July 24, 2026
alexwlchan.net · View on Hacker News

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?

Semantic search powered by Rivestack pgvector
14,736 stories · 137,719 chunks indexed