LINUX.ORG.RU

Short Answer

  is the entity used to represent a non-breaking space. It is essentially a standard space, the primary difference being that a browser should not break (or wrap) a line of text at the point that this   occupies.
Long Answer

  is the entity used to represent a non-breaking space. It is essentially a standard space, the primary difference being that a browser should not break (or wrap) a line of text at the point that this   occupies.

Many WYSIWYG HTML editors insert these   entities in an effort to control the layout of the HTML document. For example, such an editor may use a series of non-breaking spaces to indent a paragraph like this:

<P>
&nbsp; &nbsp; &nbsp; This first line of text is supposed to be indented. However, many browsers will not render it as intended.
</P>

As the example mentions, some browsers will not, in fact, indent the text because of how that particular browser handles the &nbsp; entity. Some browsers collapse multiple, concurrent non-breaking spaces into a single space. This sometimes happens, even if there are regular spaces separating the consecutive &nbsp; entities. So keep in mind that this "technique" can not be relied on.

There are some times when it is "acceptable" or "advisable" to use the &nbsp; entity so long as the consequences are understood:

1.

Its intended use of creating a space between words or elements that should not be broken. The only problems that can be associated with this use is that too many words strung together with non-breaking spaces may require some graphical browsers to show horizontal scrollbars or cause them to display the text overlapping table borders.
2.

If you need to have an empty table cell, it is often advised that you add a non-breaking space like <TD>&nbsp;</TD>. This is because some versions of Netscape seem to have problems with completely empty table cells.
3.

Indentation. It is generally discouraged to use a non-breaking space, or a series of non-breaking spaces to "force" an indentation. This practice is discouraged for two primary reasons. First, not all browsers handle the &nbsp; entity properly and may in fact ignore it when rendering the document. Second, the practice of trying to "force" a specific presentation is often frowned upon as it tends to fail and/or makes it more difficult for some readers whose browsers may be configured differently from your own.

Effect
()

Анахронизм. Используется в неюникодном хтмл. В юникодном лучше выглядит Compose+пробел+пробел (при условии, что при чтении не надо их различать)

Используется для пробела, не разделяющего слова (и как следствие, слова не переносятся отдельно друг от друга). Например: г. Москва. Некоторые особо одаренные индивиды используют его для красной строки в абзаце, хотя css решает проблему логичнее, да и при копировании лишнего мусора нет.

x3al ★★★★★
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.