As a web developer, knowing the HTML code for symbols and how to use them can give you the edge when it comes to inputting characters that do not appear on a variety of keyboards. Read on to find out more.
slide 1 of 4
Also known as a character reference codes, knowledge of HTML codes for symbols is not just important but is also inevitable in the working life of any web developer. Current character encoding sets and hardware such as the keyboard may not allow the web developer to input specific symbols into a web page directly so the only way left is to use a series of HTML codes.
There are two basic types of HTML code for symbols namely numeric character references and character entity references. These HTML codes work in a similar way to Facebook codes in that the target medium replaces the character code with the symbol.
slide 2 of 4
Numeric Character References
Numeric character references use the convention whereby the reference is formatted as &#D; where D is the representation of a positive whole number. For example & would print out an ampersand if typed into any HTML file and displayed in a web browser. We can look at four other examples which we will compare with the character entity references. We can easily display a currency symbol, a cent symbol, a copyright symbol and a registered trade mark symbol with the following HTML codes:
¤ represents the currency symbol
¢ represents the cent symbol
© represents the copyright symbol
® represents the registered trade mark
For you to be able to effectively use these codes, basic knowledge of HTML is required. Even if that is the case, it would be beneficial to read this article on how HTML works.
slide 3 of 4
Character Entity References
Character entity references work in exactly the same way as the numeric character references. The only difference here is that this type of HTML code reference is not based on positive numbers but character names. There is also a disadvantage in using the character entity references as they are not as comprehensive as the numeric character references and therefore there is no way of representing certain symbols by exclusively using the character entity references.
Examples of character representations that do not have character entity representations include the digits zero to nine, open and closing brackets, the dollar symbol and the percent symbol among others. One advantage over using these character entity references is that they are easy to memorize. Using the four examples provided above, the equivalent HTML code for those symbols are as follows:
You can see from the four examples that the naming convention for the character entities is such that the names are self explanatory. This is only true for English speaking developers. It therefore makes these easier to memorize over those that are represented by numbers.