Sunday, August 23, 2009

HTML: non-breaking space and its applications

A frequent complaint of bloggers is that when they want more than 1 spacing (beyond the single space inserted by the space bar like between here and      here), Blogger will display only 1 single space irrespective of how many times one press the space bar. Now how did I get the extra spaces above within the bracket above?

The answer is simple. Where I want a space, I type   non-breaking space. If I want more space, then all I have to do is to type in more   non-breaking space.

A frequent use of non-breaking space is when making tables. For example, we may specify <table border="1"> to create a border for a table. However, if a cell is empty, the border for that cell may not be displayed. In order to force the table to display an empty cell with a border, one can type into the cell a   non-breaking space so that it is "empty but not empty if you know what I mean" and will a blank cell with border.

  Other uses of the non-breaking space is to make indent like in the beginning of this paragraph. The non-breaking space can also be used in comments as I will demonstrate by leaving a comment after I publish this post.


  1.    This paragraph will begin with an indent created by typing by non-breaking spaces.

  2. Thanks for your wonderful posts. We have come up with a list of most helpful sites and included your blog there.

  3. UGH. PLEASE don't use nbsp to do that. There's a reason that the HTML spec says to reduce arbitrary whitespace to a single space. If you want more space between words use CSS. If you want paragraph indents use CSS.

  4. Now how would avoid the use when you want an empty cell when creating table?


Find help, info, instructions, tips, tricks

Tip: Use search box below or this box, labels in the first right sidebar, archive, ctrl+F for this page or sitemap to find topics