frydolin frydolin - 1 year ago 149
HTML Question

HTML non-breaking space is not working properly

It seems to me, that HTML entity for nonbreaking space is not working properly in my code. I use:

zvyšováním ceny – ta by negativně
but instead of the dash and two words connected together, I see an ugly white space at the beginning of the new line. Do you have any idea how to solve this problem?

I know about about a non-breaking hyphen, but please remember there is the difference between a hyphen and a dash.


**Right solution**

Answer Source

This works how it should, a line will break when there is a dash or a hyphen, but not when using a none-breaking hyphen, so by adding a   will only prevent a line break at that space, hence called no breaking space ..

.. so as a result it will break at the dash and the following   is causing the ugly white space at next line beginning

By removing the 2:nd  , like this, it will work fine and no ugly space at next lines beginning

Some text having hyp - pen that should break after the hyphen
and another with the da – sh that should break after the dash

Fiddle demo

And if you don't want it to break, the dupe link has the answers needed, either using the non-breaking hyphen or wrap it and set the wrapper to white-space: nowrap

Dupe link: No line-break after a hyphen

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download