Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do browsers render   as a regular space character?

Consider the following HTML snippet:

<p>Space&nbsp;Test</p>

When this HTML is used in a web page and the page rendered by a browser, the character actually rendered by the browser between "Space" and "Test" is a regular space character (U+0020), not a non-breaking space character (U+00A0).

(This can be observed by, for example, using the Firefox extension Character Identifier.)

I tried this in Firefox 5, Internet Explorer 8, and Chrome 12; all had the same behavior of writing out U+0020 instead of U+00A0 on the rendered web page, even though though the source document contained &nbsp; rather than a regular space character.

Why do browsers render a regular space character instead of a non-breaking space character in this way?

like image 395
Jon Schneider Avatar asked Jul 22 '11 19:07

Jon Schneider


People also ask

Why is browser rendering important?

A browser engine (also known as a layout engine or rendering engine) is a core software component of every major web browser. The primary job of a browser engine is to transform HTML documents and other resources of a web page into an interactive visual representation on a user's device.

Why do browsers render content differently?

Why Does my Website Look Different in internet explorer? Websites are made up of a set of instructions spoken in a web code language, most often HTML or CSS. Often, different browsers interpret code languages differently, which results in different interpretations.

What is rendering in browser?

What does webpage rendering mean? Rendering a webpage is the process of turning HTML, CSS, and JavaScript code into an interactive page that website visitors expect to see when clicking on a link. Every website page is designed with the end user in mind.

What is the purpose of rendering engine?

A rendering engine is software that draws text and images on the screen. The engine draws structured text from a document (often HTML), and formats it properly based on the given style declarations (often given in CSS). Examples of layout engines: Blink, Gecko, EdgeHTML, WebKit.


1 Answers

This is a relic of pre-Unicode times, when the NBSP character didn't exist in the standard character set. HTML defined the &nbsp; escape sequence as simply a space that shouldn't cause word wrapping.

like image 78
Andrew Young Avatar answered Nov 15 '22 05:11

Andrew Young