Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use &nbsp

Tags:

html

I have seen &nbsp in html and can't quite tell what it does other than create some whitespace. I am wondering what exactly it does and when it should be used?

like image 795
jlars62 Avatar asked Jun 05 '13 22:06

jlars62


People also ask

When should I use a semicolon?

Use a semicolon to join two related independent clauses in place of a comma and a coordinating conjunction (and, but, or, nor, for, so, yet). Make sure when you use the semicolon that the connection between the two independent clauses is clear without the coordinating conjunction.

When should you use a semicolon instead of a comma?

The semicolon is used when connecting two sentences or independent clauses. Unlike the comma, you do not use coordinating conjunctions, e.g., and, or, but, etc. A semicolon can also be used when connecting two independent clauses with conjunctive adverbs, e.g., however, therefore, thus, otherwise, etc.

How do you use a colon and semicolon?

Colons (:) are used in sentences to show that something is following, like a quotation, example, or list. Semicolons (;) are used to join two independent clauses, or two complete thoughts that could stand alone as complete sentences.


2 Answers

  (it should have a semi-colon on the end) is an entity for a non-breaking space.

Use it between two words that should not have a line break inserted between them by word wrapping.

There is a good explanation about when this is appropriate grammar on the English StackExchange.


It is sometimes abused to create horizontal space between content in web pages (since it will not collapse like multiple regular spaces). Padding and margins should usually be used instead of this hack.

like image 70
Quentin Avatar answered Oct 07 '22 10:10

Quentin


One reason for   is to insert multiple spaces in a document.

In HTML, multiple whitespace characters are collapsed into one space. This includes tabs and newlines.

IF you wanted to display the following:

three   spaces. 

You could insert 3   entities instead of using spaces like so:

three   spaces. 

Edit: It's worth mentioning that   is more of a historical artifact than anything else. Just about every use for it that is mentioned in the answers to this question has a better alternative means to accomplish that goal. However,   is still with us, and these are some of the things people have used it for.

See also: http://www.sightspecific.com/~mosh/www_faq/nbsp.html

like image 32
Jiaaro Avatar answered Oct 07 '22 09:10

Jiaaro