Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable line break at hyphens on Firefox

Tags:

html

css

firefox

Chrome, IE, and Safari break lines at hyphens but Firefox doesn't.

Is there any way to make Firefox break lines at hyphens, like other browsers?

like image 378
Alan Avatar asked Jan 06 '12 04:01

Alan


2 Answers

Insert the <wbr> tag after the hyphen. This tag is not present in any HTML specification (yet—it is in HTML5 drafts), but it has worked for a long time in browsers.

Firefox automatically treats a hyphen as allowing a line break after it when there are sufficiently many characters around the hyphen. But if you wish to allow line breaks more widely than that, use <wbr>, e.g. pre-<wbr>war.

like image 182
Jukka K. Korpela Avatar answered Sep 27 '22 20:09

Jukka K. Korpela


Not easily. Try inserting a zero-width space (&#8203;) after each hyphen. For example:

a-&#8203;really-&#8203;long-&#8203;hyphenated-&#8203;phrase

This will make Firefox wrap as if there's a space, but it won't visually display that space.

It's easier to implement this if you have something processing your output server-side. Just run hyphens through a quick string replace.

like image 28
benesch Avatar answered Sep 27 '22 20:09

benesch