Article may be outdated

This article is 23 days old. Some details may have changed since publication.

Hacker News·3 min read·hard

Preventing line breaks in elements

S
surprisetalk
AI Summary

A developer shares a technical solution for preventing awkward line breaks in website text and code snippets using non-breaking spaces and CSS. The approach involves automating the application of a 'nowrap' class to short code elements containing specific characters.

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.

Continue reading on Headlinne

Create a free account to read the full article.

Read full article →
technologydesign

Get the full story

Sign up for Headlinne to unlock AI insights, political bias analysis, and your personalized news feed.

Create free account

Already have an account? Sign in