In short
A translated text is not the same length as the original. The French “Ajouter au panier” becomes “In den Warenkorb legen” in German; a six-letter menu label in English can double or triple in length. Templates designed for one language then break in another: buttons that overflow, menus that wrap onto two lines, headings cut off with an ellipsis, horizontal scrolling on mobile. The task is to test each language version on the components at risk and at common screen widths, to fix the CSS so that it absorbs these variations, and to automate the check. Once it is done, no language breaks the layout.
Why it matters
The W3C points out, based on IBM's guidelines, that the shorter an English source text is, the more its translation grows in proportion:
| Length of the English text | Typical length after translation (European languages) |
|---|---|
| Up to 10 characters | 200 to 300% |
| 11 to 20 characters | 180 to 200% |
| 21 to 30 characters | 160 to 180% |
| 31 to 50 characters | 140 to 160% |
| 51 to 70 characters | 151 to 170% |
| Over 70 characters | 130% |
Short texts are precisely the ones that occupy the most constrained areas: buttons, tabs, labels, table headers, menus. German and Finnish add very long compound words that do not break. Chinese and Japanese use fewer characters, but wider and taller glyphs; Arabic and Thai need more line spacing.
The consequences are concrete. A truncated purchase button or a menu that overlaps the logo hurts the conversion of the version concerned. A word that is too long and forces horizontal scrolling degrades the mobile experience, see eliminate unintended horizontal scrolling (opens in a new tab). Text cut off by text-overflow: ellipsis remains in the HTML for search engines, but not for the visitor, who only reads part of the heading or the selling point.
These defects go unnoticed because teams mostly test the language they work in.
What it improves
- Conversion Call-to-action buttons, prices and forms readable in every language.
- Mobile experience No horizontal scrolling or overlapping.
- Visual stability Fewer layout jumps when a web font replaces the fallback font, the gap being wider with long texts.
- Brand image Each version looks designed for its language, not adapted after the fact.
- Rankings No direct effect.
How to check
Automatic detection on a page. Paste this script into the browser console, on one page in each language:
const pageWidth = document.documentElement.clientWidth
const offenders = [...document.querySelectorAll('body *')].filter((el) => {
const style = getComputedStyle(el)
if (style.display === 'none' || style.display === 'inline' || style.visibility === 'hidden') {
return false
}
const clippedWidth = el.scrollWidth > el.clientWidth + 1 && ['hidden', 'clip'].includes(style.overflowX)
const clippedHeight = el.scrollHeight > el.clientHeight + 1 && ['hidden', 'clip'].includes(style.overflowY)
const outsidePage = el.getBoundingClientRect().right > pageWidth + 1
return clippedWidth || clippedHeight || outsidePage
})
offenders.forEach((el) => { el.style.outline = '2px solid red' })
console.table(offenders.map((el) => ({
tag: el.tagName,
class: String(el.className).slice(0, 40),
text: el.textContent.trim().slice(0, 60),
})))
console.log('Horizontal scrolling:', document.documentElement.scrollWidth > pageWidth)
Expected result: an empty table and Horizontal scrolling: false. Offending elements are outlined in red. Some intentionally hidden elements (carousels, collapsed menus) also show up: sort them by eye.
Visual check. DevTools responsive mode, at widths of 320, 375, 768 and 1,280 pixels, on the homepage and one page of each template, for the longest language on your site (often German or Finnish) and for the shortest.
Components to review: call-to-action buttons, main menu and submenus, tabs, breadcrumb, comparison table headers, form labels and error messages, badges (“New”, “Sale”), product cards, cookie banner, footer, language switcher.
How to implement
Step 1 — Identify the longest language
Export the interface strings (translation files, theme strings) and compare their average length by language. Test the longest language first, along with any language with a different script (Arabic, Japanese, Thai). Note the components with the least space.
Step 2 — Simulate before translating: pseudo-localization
Pseudo-localization replaces each text with an accented, lengthened version that the team can still read: “Ajouter au panier” becomes “[Ȧĵöûţéŕ àû ƥàñîéŕ ~~~~~~]”. It reveals overflows, characters the font does not support and hard-coded text, even before translation.
Quick version, in the console, on a displayed page:
const accents = { a: 'à', e: 'é', i: 'î', o: 'ö', u: 'û', c: 'ç', n: 'ñ', A: 'Å', E: 'É', O: 'Ö' }
const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT)
while (walker.nextNode()) {
const node = walker.currentNode
const text = node.nodeValue.trim()
if (text === '' || node.parentElement.closest('script, style, noscript')) {
continue
}
const accented = node.nodeValue.replace(/[aeioucnAEO]/g, (letter) => accents[letter])
node.nodeValue = `${accented} ${'~'.repeat(Math.ceil(text.length * 0.4))}`
}
The script lengthens each text by 40% with a run of characters without spaces, which also simulates a German compound word that cannot be broken. Reload the page to get back to the original. Internationalization libraries often offer a pseudo-locale built into the build (for example through a plugin for i18next): enable it in the staging environment.
Step 3 — Fix the CSS
The fixes that absorb most variations:
.button {
min-inline-size: 8rem;
padding-inline: 1rem;
white-space: normal;
text-wrap: balance;
}
h1, h2, h3, .card-title {
overflow-wrap: break-word;
hyphens: auto;
}
.main-menu {
display: flex;
flex-wrap: wrap;
gap: 0.5rem 1.5rem;
}
.badge {
max-inline-size: 100%;
overflow-wrap: anywhere;
}
Design rules:
- Minimum widths rather than fixed ones:
min-widthandpadding, neverwidth: 120pxon a button. - No fixed height on a block that contains text; use
min-height. - Automatic hyphenation:
hyphens: autobreaks long words according to the language's rules, provided thelangattribute is correct. See set html lang on each page (opens in a new tab). overflow-wrap: anywhereas a last resort, for URLs, references and words that cannot be hyphenated.- Menu breakpoints: switch to the collapsed menu earlier, or set the breakpoint based on the longest language.
- Truncation with an ellipsis reserved for secondary content (card titles in a list), never for buttons or prices.
- No text in images: it cannot be translated and does not adapt.
For a fix specific to one language, target it: :lang(de) .main-menu { font-size: 0.95rem; }. Still, prefer a rule that works for all of them.
Step 4 — Automate with Playwright
A test that goes through the key pages of each language at several widths, checks for the absence of horizontal scrolling and truncation, and saves screenshots:
// tests/overflow.spec.ts
import { test, expect } from '@playwright/test'
const paths = ['/fr/tarifs/', '/de/preise/', '/en/pricing/', '/ar/']
const widths = [320, 375, 768, 1280]
for (const path of paths) {
for (const width of widths) {
test(`${path} at ${width} px`, async ({ page }) => {
await page.setViewportSize({ width, height: 900 })
await page.goto(`https://example.com${path}`)
const scrolls = await page.evaluate(
() => document.documentElement.scrollWidth > document.documentElement.clientWidth,
)
expect(scrolls).toBe(false)
const truncated = await page.evaluate(() =>
[...document.querySelectorAll('button, a, h1, h2, h3, label, th, nav li')]
.filter((el) => getComputedStyle(el).display !== 'inline')
.filter((el) => el.scrollWidth > el.clientWidth + 1)
.map((el) => el.textContent?.trim().slice(0, 60)),
)
expect(truncated).toEqual([])
await page.screenshot({ path: `screenshots/${path.replaceAll('/', '_')}${width}.png`, fullPage: true })
})
}
}
Run npx playwright test. The screenshots allow a quick visual review, language by language. To go further, Playwright's visual comparison (expect(page).toHaveScreenshot()) detects any regression from one release to the next. Add this test to the deployment pipeline: see integrate multilingual tests into CI/CD (opens in a new tab).
Step 5 — Keep a log
| Page | Language | Width | Component | Problem | Fix | Status |
|---|---|---|---|---|---|---|
/de/preise/ |
de | 375 px | “In den Warenkorb legen” button | Text on one line, overflows the button | white-space: normal, min-inline-size |
Fixed |
/fi/ |
fi | 768 px | Main menu | Overlaps the logo | Switch to the collapsed menu at 1,024 px | In progress |
/ja/ |
ja | 1,280 px | Card title | Clipped vertically | Fixed height removed | To do |
On WordPress, Shopify and CMSs
The same tests apply: open each language in preview (Polylang, WPML, Shopify languages) and run the detection script. On WordPress, fixes go into the child theme's additional CSS (Appearance > Customize > Additional CSS for a classic theme, or the Site Editor's Styles menu for a block theme); on Shopify, into the theme's CSS file (assets/). When an interface text that is too long comes from a translation supplied by the theme, shorten the translation rather than distorting the template, in agreement with the translator.
Common mistakes
- Testing only the team's working language, often the shortest.
- Fixed pixel widths on buttons, tabs and badges.
white-space: nowrapon translatable menu or button labels.- Ellipsis truncation on a call-to-action button or a price.
- Shortening translations with abbreviations: the abbreviation does not always exist in the other language and hurts understanding.
- Forgetting states: form error message, hovered or disabled button, filled cart.
hyphens: autowithout a correctlangattribute: no hyphenation is applied.
Frequently asked questions
How much longer does a text get once translated?
It depends on the length of the original text and on the language. According to IBM's guidelines, cited by the W3C, an English text of under ten characters can reach two to three times its length once translated into a European language, and a text of over seventy characters about 130%. Short buttons and labels are therefore the most exposed. Always test with the real translations, not just an estimate.
What is pseudo-localization?
Pseudo-localization automatically replaces every interface text with an accented and lengthened version, for example by 30 to 40%, which the team can still read. Before translation, it reveals texts that overflow, characters the font does not contain and strings hard-coded in the code, which remain unchanged. Many internationalization libraries offer it as a test language to enable in staging.
Should overly long texts be truncated with an ellipsis?
Not for important elements. Truncation hides part of the button, the price or the selling point from the visitor, even if the full text stays in the HTML. Reserve it for secondary content, such as headings in a list of cards that link to the full page. Elsewhere, let the text wrap, use automatic hyphenation with a correct lang attribute, and plan minimum widths rather than fixed ones.
How do you detect text overflow automatically?
In the browser, compare each element's content width, scrollWidth, with its visible width, clientWidth, keeping only elements whose overflow is hidden. Also check that the whole page does not scroll horizontally. A console script is enough for a one-off check; a Playwright test that goes through each language's pages at several screen widths lets you repeat it on every deployment.
Resources
- W3C: Text size in translationw3.org
- MDN: hyphens propertydeveloper.mozilla.org
- MDN: overflow-wrap propertydeveloper.mozilla.org
- MDN: CSS logical properties and valuesdeveloper.mozilla.org
- Playwright: Screenshotsplaywright.dev
Updated on
Topic checklist (PDF)