Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is   allowed to make space in terms of semantic, web standards and accessibility and cross browser compatibility?

Is   allowed to make space in terms of semantic, web standards and accessibility and cross browser compatibility?

like image 847
Jitendra Vyas Avatar asked Nov 07 '09 15:11

Jitendra Vyas


2 Answers

The reason it was invented was to prevent line breaks (in fact it's an acronym "non-breaking space"), however it's obsolete: You should use the "white-space:nowrap;" CSS attribute.

Whatever you do, NEVER use it to indent or as a "separator" between, for example, table cells.

<p>Hello&nbsp;to&nbsp;you</p>

Is equivalent to the preferred form

<p style="white-space: nowrap">Hello to you</p>
like image 192
Thomas Bonini Avatar answered Nov 05 '22 04:11

Thomas Bonini


Since you tagged your question with “XHTML”, the answer is “it depends”.

If you serve your XHMTL documents as XML then Firefox will not read entities from the DTD file. As a consequence, it won’t recognized named entities such as &nbsp;. However, this is a rare case because XHTML documents are normally served as HTML to accommodate non-supporting browsers (= MSIE).

That said, “make spaces” is a rather nebulous term. You should use CSS to position your elements and put indentations in the text (other than source code inside a <pre> tag). Do not use spaces for formatting purposes, ever (the same is true in text processing applications). This isn’t acceptable semantically and it will screw with your layout as soon as the users have some custom settings enabled in their browsers. Non-breaking spaces are only to be used, as the name indicates, to prevent a break between things that belong on one line, e.g. a product name and the product version number: e.g. “Ubuntu 10&nbsp;9.10”, or inside a telephone number or in formulae.

like image 5
Konrad Rudolph Avatar answered Nov 05 '22 05:11

Konrad Rudolph