Thursday, January 31, 2013

Special Characters in HTML

Certain characters are not available on some keyboards, and some characters, if used in HTML code will be interpreted by the browser as code, rather than literal letters. For example, "<" and ">" all by themselves would be thought of as TAGS by the browser. When writing HTML code, I have had to use special characters to write these so they show up as < or >!

Note: some wysiwyg HTML editors will rewrite these so you do not get the symbol in the browser. That is when you write π it doesn't recognise it and writes the HTML as &amppi; - which is not intended! Left alone, they work fine in browsers!
To write, for example:
You actually have to write:
Where < is the special character for <. Instead of using < - the less than sign - you could use the number, which in this case is 60, as follows:
And instead of using the > special character, called greater than, you could use its number form, which is:
On other occasions, you might want to write something that is not on the keyboard, for example
Where you would have to write in the HTML code &#247; or ÷ to get that symbol. People who need to write mathematical formulae or languages which do not use the English script, find the special characters extremely useful. The rest of us have only an occasional need for one or two of them. Following is a list of some that I personally have used:

Occasionally it is better to use the proper ellipsis rather than to type three dots.
>&#062>Mainly for writing HTML tutorials!
&amp#151 or &#8212When I want a long dash to break up some text!

The delightful non-breaking space,  

The non-breaking space does crop up now and again when writing HTML. If you want an empty table cell, then you have to put a non-breaking space in it. Similarly, if you want to leave some lines using , then you need to put a non-breaking space between the 's, otherwise you won't get your lines.
The following are characters I found interesting, but they have limited use for me!


No comments: