I added a few lines of CSS to my own site, andrewbackhouse.design, for one simple reason. I wanted the text to look more presentable and more professional. Most of all on a phone, which is where most people read it.
The CSS turns on hyphenation. That means the browser can split a long word at the end of a line, with a hyphen, the way a book or a newspaper does. It sounds like a tiny thing. On a small screen, it is one of the quickest ways to make a page look cared for.
This post explains what the code does, line by line, and why I think it is worth having. It is for business owners who want to know what is going on, and for junior designers who want to try it.
The problem on a phone
On a phone, a line of text only holds a handful of words. When a long word does not fit, the browser pushes the whole word down to the next line. That leaves a big gap at the end of the line above.
Do that a few times in one paragraph and the right-hand edge starts to look chewed. Short line, long line, short line. Words like “accommodation”, “refurbishment” and “consultation” are the usual culprits, and plenty of Harrogate businesses use them.
Nobody will email you to say your paragraphs look gappy. But people notice when a page looks rough, even if they cannot say why. It also makes the text a little harder to read, because the eye has to work harder to find the start of each line.
Hyphenation fixes this. The browser can now break that long word in a sensible place, so the lines stay closer to the same length.
Step 1: tell the browser what language you write in
Before any of the CSS works, the browser needs to know your language. It uses a dictionary for each language to work out where a word can be split. If it does not know the language, it will not hyphenate at all.
You set this with the lang attribute at the top of your page, like this:
<html lang="en-GB">
If your site runs on WordPress, you do not need to touch any code. Go to Settings, then General, and check that Site Language is set to English (UK). WordPress adds the right lang attribute for you.
Step 2: add the CSS
Here is the code I use on my own site. It is based on the set-up Richard Rutter shares in his article All you need to know about hyphenation in CSS. It is well worth reading if you want to go further.
p {
hyphens: auto;
hyphenate-limit-chars: 6 3 2;
hyphenate-limit-lines: 2;
hyphenate-limit-zone: 8%;
hyphenate-limit-last: always;
-webkit-hyphenate-limit-before: 3;
-webkit-hyphenate-limit-after: 2;
-webkit-hyphenate-limit-lines: 2;
}
.pn, abbr {
hyphens: manual;
}
It looks like a lot. It is really one switch, plus a few rules to stop the browser getting carried away.
Notice it only applies to paragraphs. Headings are short and big, and a hyphen in a heading nearly always looks wrong.
What each line does
hyphens: auto
This is the switch. It lets the browser split words in paragraphs when it needs to. Everything else in the code is there to keep it tidy.
hyphenate-limit-chars: 6 3 2
This sets three limits. The browser only splits words that are 6 letters or longer. It must leave at least 3 letters before the hyphen and at least 2 after it.
So short words like “about” stay whole. And you never get two letters left hanging at the end of a line, like “re-“, which is hard to read.
hyphenate-limit-lines: 2
No more than two hyphens in a row down the right-hand edge. Typesetters call a stack of hyphens a ladder. It looks fussy and it is tiring to read.
hyphenate-limit-zone: 8%
This one needs a bit more explaining. Picture a narrow strip down the right-hand side of the paragraph, 8% of its width. If the next word would start inside that strip, the browser moves it down whole instead of splitting it.
In plain terms, a small gap at the end of a line is fine. The browser only reaches for a hyphen when the gap would be big. My text is left aligned, so a slightly ragged edge is normal. This line trades a little more rag for fewer hyphens.
hyphenate-limit-last: always
This stops the last word in a paragraph being split. Half a word sat alone on the final line looks odd. A slightly shorter line above it is much nicer.
The three -webkit- lines
Safari does not understand some of these rules yet. These three lines say the same things in a form it does know. The first two give Safari the 3 letters before and 2 after rule. The third gives it the limit of two hyphens in a row.
Safari is the browser on most iPhones, so this matters.
Keeping names in one piece
You do not want your business name, or a customer’s surname, broken in half. “Harro-gate” in the middle of a sentence looks like a mistake. The same goes for abbreviations.
The last part of the code deals with this. hyphens: manual tells the browser not to split these words by itself. It will only break them at a hyphen that is already in the word.
The abbr tag is the standard way to mark up an abbreviation, so those are covered straight away. For names, wrap them in a span with the class pn, short for proper noun:
<span class="pn">Harrogate</span>
You do not need to do this for every name on your site. I only bother with names long enough to get split, and that would look silly if they were. Your business name is the one to start with.
An honest word about browser support
Hyphenation itself works in all the main browsers. The word length limit works in Chrome, Edge and Firefox, and in Safari through the -webkit- lines. Safari also follows the two hyphens in a row limit, for the same reason.
The rest are part of the CSS standard, but most browsers do not act on them yet. So why include them?
Because a browser simply skips any line of CSS it does not understand. Nothing breaks. And when support arrives, your text gets tidier without you doing a thing. The basics work today, and the extras arrive when browsers catch up. I think of it as leaving the door open.
How to check it is working
Open a page with a few long paragraphs on your phone. Or make your browser window narrow on a laptop. You should see long words split with a hyphen, and a right-hand edge that looks calmer than before.
If nothing changes, check the language setting from step 1 first. Nine times out of ten, that is the reason.
Why it is worth doing
- Your pages look finished. People decide very quickly whether a business looks like it takes care, and tidy text is part of that.
- Paragraphs are easier to read on a phone, with fewer big gaps to trip over.
- Your business name stays whole.
- You set it once. It then works on every paragraph across the whole site, including ones you write next year.
It is a small detail. But small details are what make a website feel looked after, and that is how you want customers to feel about your business too.
Want this on your website?
If you would like me to add this to your site, get in touch. I will set it up, check it on a few different phones, and make sure your business name stays in one piece.


