seed
seed

Reputation: 71

What's the difference between &nbsp and  ?

What's the difference between the two   and &nbsp if both of them produces the same output?

Thanks!

Upvotes: 1

Views: 1228

Answers (1)

Quentin
Quentin

Reputation: 943561

  is a non-breaking space; use it instead of a normal space between two words that should be rendered on the same line even if word wrapping would normally prevent that.

&nbsp is (in HTML 5) an error that you depend on browsers to recover from.

See the specification:

The ampersand must be followed by one of the names given in the named character references section, using the same case. The name must be one that is terminated by a ";" (U+003B) character.

The semi-colon is optional, in some circumstances (e.g. when followed by a non-name character), in HTML 4.x and earlier.

Upvotes: 7

Related Questions