Preventing line breaks in <code> elements
Trending on Hacker News: Preventing line breaks in <code> elements (11 points / 18 comments, via alexwlchan.net)
Opening excerpt
One of my favourite tiny details in this website is my non-breaking spaces . I have code that looks for phrases like “5 cm”, “New York”, or “Objective‑C”, and inserts a non-breaking space/hyphen so they’ll never be split across multiple lines.
Previously I was only applying this detail to body text, but today I implemented something similar for elements.
I used a lot of inline code snippets in my last post , and while reviewing it I noticed that several of those snippets had unhelpful line breaks. For example, (?-u:…) was split into (?- and u:…) , while the flag —multiline was split with - on one line and -multiline on the other. These line breaks make the post harder to read, with no benefit.
I could fix this by replacing the hyphen in my with a non-breaking hyphen, but people copy/paste code snippets and that might change the meaning.
(Excerpted from the original; full article via the source link below.)
This story hit the Hacker News front page today (11 points / 18 comments, via alexwlchan.net). Our Tech Radar aggregates daily signals on AI engineering, backend architecture and DevOps — browse the related services and further reading below, or get in touch with our team.
Source: Hacker News