What's The Opposite of a Nbsp

What's the opposite of a nbsp?

You want the unicode character ZERO-WIDTH SPACE (\u200B).

You can get it in HTML with or .

Explicit breaks and non-breaks:

LB7 : Do not break before spaces or zero width space.

LB8 : Break before any character following a zero-width space, even if one or more spaces intervene.

http://unicode.org/reports/tr14/

Breaking space (opposite of non-breaking space)

is a regular space (by its numeric ASCII value).

HTML opposite of non-breaking space

Maybe the Unicode zero-width space would help: http://www.fileformat.info/info/unicode/char/200b/index.htm

The HTML entity is e.g.
over​flow will break the word between "over" and "flow" only when the full word doesn't fit.

Are there other whitespace codes like   for half-spaces, em-spaces, en-spaces etc useful in HTML?

Yes, many.

Including, but not limited to:

  • [ ] hair space :  or
  • [ ] 6-per-em space : (no character reference available)
  • [ ] narrow no-break space : (no character reference available)
  • [ ] thin space :  or
  • [ ] 4-per-em space : or
  • [ ] non breaking space :   or  
  • [ ] punctuation space :  or
  • [ ] 3-per-em space : or
  • [ ] en space : or
  • [ ] figure space : or
  • [ ] em space : or

span{background-color: red;}
<table>
<tr><td>non breaking space:</td><td> <span> </span> or <span> </span></td></tr>
<tr><td>narrow no-break space:</td><td> <span> </span></td></tr>
<tr><td>en space:</td><td> <span> </span> or <span> </span></td></tr>
<tr><td>em space:</td><td> <span> </span> or <span> </span></td></tr>
<tr><td>3-per-em space:</td><td> <span> </span> or <span> </span></td></tr>
<tr><td>4-per-em space:</td><td> <span> </span> or <span> </span></td></tr>
<tr><td>6-per-em space:</td><td> <span> </span></td></tr>
<tr><td>figure space:</td><td> <span> </span> or <span> </span></td></tr>
<tr><td>punctuation space:</td><td> <span> </span> or <span> </span></td></tr>
<tr><td>thin space:</td><td> <span> </span> or <span> </span></td></tr>
<tr><td>hair space:</td><td> <span> </span> or <span> </span></td></tr>
</table>

How to keep   without empty space?

In CSS, try:

white-space:break-spaces

Tab character instead of multiple non-breaking spaces (nbsp)?

It's much cleaner to use CSS. Try padding-left:5em or margin-left:5em as appropriate instead.

Difference between and  

is the classic space, the one you get when you hit your spacebar, represented by his HTML entity equivalent.

  and   represents the non-breaking space, often used to prevent collapse of multiple spaces togethers by the browser :

" " => " " (collapsed into only one space)

"    " => "    " (not collapsed)

If you are parsing a string containing both classic and non-breaking spaces, you can safely replace one by the other.

What is   and does it affect perfomance of a webpage?

It is a character entity for a non-break space.

It means that it the space will not be collapsed when viewed in a browser (as whitespace is normalized and ignored in HTML).

The only proper use of it is to ensure that certain words will not wrap (if you always want them to appear on the same line). For example Open University - will not wrap.

It doesn't effect performance, apart from the added characters that get transmitted.

In earlier times, before CSS was widely used,  s were used in conjunction with tables for layout. These days, you should use CSS for layout.

Tab character instead of multiple non-breaking spaces (nbsp)?

It's much cleaner to use CSS. Try padding-left:5em or margin-left:5em as appropriate instead.



Related Topics



Leave a reply



Submit