logoalt Hacker News

Preventing line breaks in <code> elements

14 pointsby surprisetalkyesterday at 2:20 PM19 commentsview on HN

Comments

danlittyesterday at 3:10 PM

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.

show 7 replies
pwdisswordfishqyesterday at 4:33 PM

Why even bother with the CSS class? Just apply text-wrap: nowrap; to all <code> elements and dispense with the fragile regex parsing.

dajtxxtoday at 2:11 AM

The 5 cm example had a line break between the 5 and the cm when I read the page in my phone. A joke?

pimlottcyesterday at 4:49 PM

Unfortunately this makes it much harder to read on narrow-width screens (e.g. mobile), where the use must scroll horizontally