开发者

What is   and does it affect perfomance of a webpage?

While I code in Visual Studio, I h开发者_C百科ave lot of  

I know its a non-breaking space, but my question is whether its absence or presence can help to better web page performance?

Why is it and for what it is needed??


It is a character entity for a non-break space.

It means that it the space will not be collapsed when viewed in a browser (as whitespace is normalized and ignored in HTML).

The only proper use of it is to ensure that certain words will not wrap (if you always want them to appear on the same line). For example Open University - will not wrap.

It doesn't effect performance, apart from the added characters that get transmitted.

In earlier times, before CSS was widely used,  s were used in conjunction with tables for layout. These days, you should use CSS for layout.


But my question is whether its absence or presence can help to better web page perfomance ?

More characters means more data to serve, means slower loading … but it is text so not significantly slower loading.

Why is it   for what it is needed ??

A non-breaking space is placed between two words which should not word wrap.

e.g. HMS Brilliant will always be rendered as two words on the same line. You won't get HMS at the end of one line and Brilliant at the start of the next. The line break will occur before the HMS instead of between it and Brilliant.

As a side effect to it not being normal white space, HTML parsers will not collapse it into a single space. As a consequence, some people and tools abuse it to fake margins, padding and tabs.


When you use regular whitespace in html, the browser will compress consecutive whitespace to a single space. "try    this" will become "try this".

When you want (for layout purposes) more spaces, you need something else. And that is   which is not seem as compressible whitespace.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜