Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between   and space?

There are two snippets of HTML code:

1.

<div>&nbsp;</div>

2.

<div> </div>

I run them in Chrome 43.0.2357.130m separately.

The first snippet's div has height(height=18px), but the second doesn't have height(height=0).

I wonder why they have different result.

Thank you:-)!

like image 714
tianzhi0549 Avatar asked Jul 11 '15 09:07

tianzhi0549


People also ask

What is the meaning of the phrase difference between?

countable noun. The difference between two things is the way in which they are unlike each other. That is the fundamental difference between the two societies. [ + between] There is no difference between the sexes.

What is difference between different and difference?

“Difference” is a noun, while “different” is an adjective.

What is difference between and among?

The most common use for among is when something is in or with a group of a few, several, or many things. The most common use of between is when something is in the middle of two things or two groups of things.


1 Answers

&nbsp is a non-breakeable space. It means that it is always interpreted as a character. For exemple, two words separated with a &nbsp: will always stay together, but two words separated with a space can be separated by a new line if the container is too small.

A simple space is like "Meh, I'm here if you need me, but I can change if you want me too <3", a &nbsp is more "I'm ALWAYS here"

In you exemple, the space seems useless (no words before and after) so it desappear. The &nbsp is still here. Consider the &nbsp as the same way that if it was an invisible letter more than a space.

like image 194
MetalFoxDoS Avatar answered Oct 01 '22 14:10

MetalFoxDoS