Nonbreaking Space and No-Width Optional Break

19:06
Mon
12
Dec 2016

Nonbreaking Space and No-Width Optional Break

Wrapping text on word boundaries instead of single character boundaries is a great invention. A text looks so much better when inserted to Word:

Than when printed in oldschool console:

But there are places where we may not want a line break to be possible despite we insert a space. For example, in Europe we use space as thousand separator (and comma as decimal mark) when writing down numbers.

A special character called "nonbreaking space" is very helpful in such cases. You can insert it in Word by clicking: Insert > Symbol > More Symbols > Special Characters > Nonbreaking space. This character looks like space, but it doesn't cause line break.

You can actually see this "invisible" character when you press Ctrl+*. It looks like a small circle or a degree sign.

In HTML you can specify a non-breaking space as:  .

I have discovered quite recently that there is also an opposite special character, called "no-width optional break" or "zero-width space". It is useful in cases where you have a long sequence of characters (like a file path) and you want it to be broken across lines despite it doesn't contain any spaces. It is especially important when you use text justification, because such a long text moved to separate line as a whole can cause an ugly effect:

You can insert this special character in Word (e.g. after every backspace in the path) by clicking: Insert > Symbols > More Symbols > Special Characters > No-width optional break. It occupies no space, but it tells the word processor that a line can be broken at this point. Now it looks much better:

When you press Ctrl+*, you can see this special character depicted as a rectangle.

In HTML you can also use it by typing: ​. It's Unicode "Zero Width Space" character.

Comments (0) | Tags: html | Author: Adam Sawicki | Share

Comments

(No comments)

Post comment

Nick *
Your name or nickname
E-mail
Your contact information (optional, will not be shown)
Text *
Content of your comment
Calculate *
(* - required field)
STAT NO AD [Stat] [Admin] [STAT NO AD] [pub] [Mirror] Copyright © 2004-2017 Adam Sawicki
Copyright © 2004-2017 Adam Sawicki