This is one of those posts that you never thought you’d be reading. Spaces, how basic a topic is that? It’s almost ridiculous. A no-brainer. The   is a "HTML character entity" which is just a fancy way of saying it’s a HTML way of displaying characters that may not appear on your keyboard. The two common ways to access these special creatures is to use special HTML. For example, if you wanted to show the cent sign (¢) you can enter ¢ or ¢ in your HTML. All character entities start with a pound sign (#) and end with a semicolon (;). There are plenty of cool or unusual HTML character entities available out there like the club ♣ (♣), the quarter fraction ¼ (&#188), the infinity symbol ∞ (∞) and many more. Note that not all HTML character entities are available in every font and every OS, so sometimes you might get unexpected results, especially with the more obscure characters.

But the space? Why does the space need a special code (  or  )? Well technically   and   aren’t just spaces, they’re non-breaking spaces. What’s so special about that you ask? The difference between "just an average space" and the "non-breaking space" is that while a typical space between text will allow the text to be broken up on multiple lines, the non-breaking space does just what it’s name implies and prevents the text from breaking. Here’s a quick example. Let’s say you have some text that is being squeezed due to other elements on your page. So the text "non breaking text" ends up like this:

Example:

non breaking space

You can see that the text has been broken up on multiple lines. What happens if we absolutely need to have the text all on one line and want to prevent the browser from automatically breaking it? This is where the non-breaking space comes in handy. By substituting regular spaces with non-breaking ones you get:

Example:

non breaking space

This obviously breaks the 50 pixel width we specified, however it does keep the text from breaking. Now if you’re like me, you’ve known about the   tag forever and never given it a second thought. You might also have run into it when looking at code from other folks or from some HTML editors, especially when people try to indent things manually like:       Section 1. Older versions of FrontPage were especially guilty of trying to be overly helpful by using   in places that it didn’t belong, or when content was pasted into it. Older versions of Netscape also used to pitch a fit if a table cell was encountered with no content in it and the easy workaround was to throw a   tag in the cell to appease the browser. Thankfully most of today’s better HTML editors know when to properly apply the   tag and now so do you.

Note: Also check out the <nobr> tag (which was never a formal part of any HTML standard) and CSS nowrap attribute.