HOME →  HELPFUL HINTS MENU     Delicious.Com Bookmark this on Delicious StumbleUpon.Com  Recommend at StumbleUpon

How to include special characters in HTML when you are publishing on the internet



Note that this page is for people publishing on the 'net. For help with other internet topics, go back to the main "helpful hints" menu and choose again.

This page used to contain a great deal of other information. That has was moved to a page of its own in September 2011. Only the information about special characters has been left here.

Some of the following will be easiest if you edit your pages "by hand", i.e. by working directly with the html that you put on your website host. For example, writing your html using Notepad (or, better (it has spell check, automatic text and syntax highlighting) Textpad) will facilitate applying the hints below. If you use some of the "do it for you" WYSIWYG html editors, it may be difficult or impossible to achieve the fine control needed for some of the following.


Special characters

To put ordinary letters or digits into a web page, you just type them normally, as you would for a word processor. However, some characters and punctuation marks require a different approach. Most immediately obvious are the < and > symbols. You can't type them normally and expect the html browser rendering your page to realize that you don't want them to signify an html tag. Neither can you use an ampersand (&) without "a trick", as should become obvious to you in a moment.

If you use your browser's "View page source" tool, you can see how I make the < and > symbols appear in this text. All I've done is type an ampersand (&), a short code, "lt" or "gt" ("Less Than" and "Greater Than") in these cases, and a semicolon (;).

You can sometimes get away with typing something directly, but you will improve the chances that your readers will see what you intended, in spite of their browser, in spite of settings in their machine, in spite of their operating system, if you use the following. What you see on your screen is not always what they will see on theirs, if you don't stick to the correct HTML protocols.

I would like to thank Chris Bates for his Web Programming, by ISBN 0-470-84371-3, for the following, which started life as a mere selection of the special characters listed in his book....

A "Special" Special Character: &nbsp: Don't use it! Use &emsp; (or &#8195;) instead. (There's serious information on this point at Wikipedia's article. You may also enjoy the humorous rant about the use of &nbsp which I found.)

Sample // Description //  What goes inside the & and the ;

 -  (For how to do spaces, see below)
 <   Less than lt (Very useful for publishing pages explaining HTML!)
 >   Greater than gt
 ≠   Does not equal ne
 ≥   Greater than or equal to ge
 ≤   Less than or equal le
 £   Currency: British pound sign pound
 €   Currency: Euro euro
 ¢   Currency: cent cent
 ±   Plus-or-minus plusmn
 8°   Degree sign (after an ordinary "8") deg
 8²   Superscript two (after an ordinary "8") sup2
 8³   Superscript three (after an ordinary "8") sup3
    (See below for doing other text as superscript or subscript)
 µ   Micro- micro
 π  Pi pi
 ←  Left arrow larr
 →  Right arrow rarr
 ⇐  Double left arrow*NO lArr
 ⇒  Double right arrow*NO rArr
 »  Right dbl quote arrows raquo
 «  Left dbl quote arrows laquo
 ›  Right single quote arrow rsaquo
 ‹  Left single quote arrow lsaquo
 ↑  Up arrow uarr
 ↓  Down arrow darr
 ∼  Tilde*NO sim
 ˜  Small tilde tilde
 &  ampersand amp
 X–X  En-dash ndash (Shown between two ordinary X's)
 X—X Em-dash mdash (Shown between two ordinary X's)
 ©   Copyright copy
 ®   Registered trademark reg ("TM" can indicate an unregistered trademark, by the way)
 X·X "Mid-dot" middot (Shown between two ordinary X's)


You can say Sheepdog Software® like that, or perhaps you'd rather it looked like this: Sheepdog Software®. That was done by using the <sup> tag, which is explained more fully down the page.

As noted above, it is a Bad Idea to use &nbsp for a space or spaces, unless you are using it for what it was intended for: to "glue" two (or more) words together, so that if one needs to be moved down to the next line, they both are. (nbsp: Non-Breaking SPace). I will discuss what you properly can use in a moment, but first notes on the abbreviations in the table....

The notations "*" and "NO" in the table above are somewhat dated, but for what it is worth...
  Tags marked "*" didn't work on my machine with IE 5.0 or IE 6. They worked with Firefox and most worked with Opera... well, versions of Firefox and Opera current when IE was current!
  Tags marked "NO" didn't work... years ago... on my machine with Opera 8.51. They produced little boxes.

In July 2012, there was a great resource for things like the brief tables above at http://www.w3schools.com/tags/ref_entities.asp.

Horizontal space within text, or as indents: I read somewhere that &ensp and &emsp were for "n" space" and "m space"... horizontal spaces of different widths... but they didn't work on my machine with Firefox 1.0.7. They work fine with FireFox 3, FireFox 6, and probably have done so for some time. In the early days, they produced nothing, not even an ordinary space. Of course, if you are into CSS, etc, there are probably better ways to lay things out, but in the meantime, I will be using "bad" kludges which Get The Job Done...

The failure to work of &ensp and &emsp was particularly annoying. You try to do something "properly", and get no result. (By the way, you will soon discover, if you try it, that multiple ordinary spaces in HTML don't work... they often get treated as a single space.) The &ensp and &emsp seemed to be what we should use if we want to create horizontal space with tags. And today (9/11), they do seem to work. Hurrah! (There are other, grander, ways, but I like things Simple.) (Here's a test: Between the following xx's there is, first an &ensp; and then, between the second and third, an &ensp;: X X X.) If you'd rather not trust them, here's another answer... You can use Unicode characters.

For an "en space", if you don't like simply using &ensp;, you can use &#8194. Here are two x's with an &#8194; between them: x x.

For an "em space", wider than an "en space", if you don't like simply using &emsp;, you can use &#8195. Here are two x's with an &#8195; between them: x x. (The "em quad", #8193, gives the same result, with FireFox 6, anyway, but the only available HTML tag (&#8195;) is not as recognizable.)

Unicodes 8196-8202 provide a range of other spaces, but they don't move in a nice sequence from narrowest to widest across that range of Unicodes.

For details, and for more than you ever knew could be said about what is, at the end of the day, a close cousin of a vacuum, see the Wikipedia article on spaces in typography.




Click here to go to the site's MAIN index... Helpful Hints is just one corner of the site.





Looking for email, domain registration, or web site hosting? If you visit 1&1's site from here, it helps me. They host my website, and I wouldn't put this link up for them if I wasn't happy with their service. They offer things for the beginner and the corporation.


Ad from page's editor: Yes.. I do enjoy compiling these things for you. I hope they are helpful. However... this doesn't pay my bills!!! Sheepdog Software (tm) is supposed to help do that, so if you found this stuff useful, (and you run a Windows or MS-DOS PC) please visit my freeware and shareware page, download something, and circulate it for me? Links on your page to this page would also be appreciated!
Click here to visit editor's freeware, shareware page.

How to email or write this page's editor, Tom Boyd


Valid HTML 4.01 Transitional Page tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org It almost passes! There are two "problems" which I have reasons for overlooking... but usually problems can (and should) be solved!


Why does this page cause a script to run? Because of the Google panels, and the code for the search button. Also, I have my web-traffic monitored for me by eXTReMe tracker. They offer a free tracker. If you want to try one, check out their site. Why do I mention the script? Be sure you know all you need to about spyware.

....... P a g e . . . E n d s .....