Hyphen and the differences between Firefox and other browsers

Firefox also seems to display a hyphen, and then  differently in other browsers. Here are some test codes that demonstrate the problem:

<html>
<body>
    <div style="border: 1px solid blue;width: 50px">
        This text can break. Do&nbsp;not&nbsp;-&nbsp;break&nbsp;this&nbsp;text.
    </div>
</body>
</html>

Note that in Firefox, the second sentence will not break, but in Chrome and IE it breaks into a hyphen.

Does anyone know a good workaround so that the break does not occur?

+3
source share
2 answers

The problem is that the minus sign in your code allows breaking. There are many ways you can write a horizontal line in HTML. &ndash;, &mdash;, -. There is a “List Separately” article describing all possible methods.

Unicode, . - " ", : &#8209;.

, .

+6

, CSS-: nowrap;

0

Source: https://habr.com/ru/post/1737100/


All Articles