没有人de

昨天不能唤回来,明天还不确实,而能确有把握的就是今天。今日一天,当明日两天。 -- 耶曼逊

博客园 首页 新随笔 联系 订阅 管理

What is  ? Is it needed?

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. It's 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.

posted on 2005-06-13 17:12  没有人  阅读(352)  评论(0)    收藏  举报