&nbsp: No-break Space HTML

The   character is called a no-break space and it’s a character entity. There are two situations where you may need to use a no-break space:

1. Keep elements together

If you want to put space between two elements, but the browser should not break up these two parts in separate lines then replace the ordinary space with a no-break space. For example, you want to write this These are the results : . You would want to keep the “:” attached to the line and not let the browser render it on a separate line when there is no free space on the line. Without a no-break space it could show up like this,

These are the results
:

Replace the space before the semicolon with   and the “:” will stick to the preceding word, so it will always look like this,

Example:
These are the results :

Result:
These are the results :

2. Create multiple spaces

The other use of this character is where you want to show multiple spaces in a text. Because normal spaces are collapsed to only one by the browser, no-break spaces are needed here:

Example:
These spaces will collapse, but these & are & shown.

Result:
These spaces will collapse, but these    are    shown.

Source:
http://www.xs4all.nl/~dimaroan/htl/faq1.html

You May Also Like

Leave a Reply?