Kamis, 02 Desember 2010


HTML entities (also known as character entity references) enable you to use characters that aren't supported by the document's character encoding or your keyboard. For example, you can type © to output a copyright symbol.
You can also use numeric character references. Numeric character references can be defined with either a decimal or hexadecimal value (although decimal is more common). The numeric character reference for the copyright symbol is © (decimal) and © (hexadecimal).
A key benefit that numeric character references have over entities is that they can be used to specify any unicode character, whereas entities can only specify some.

Entity Example

Many web developers use entities for outputing HTML code to the browser (or at least, outputing one of the characters used by the HTML language).
Lets say you have a website about web design. And lets say you want to display the tag required for creating a horizontal rule 20% wide. Well, if you type the tag (

) into your code, the browser is simply going to render it as it should be (rather than output the actual code example). Like this...

... you see, instead of displaying the code, the browser rendered the code.
What you should have typed in is this:
<hr width="50%" />
The < replaces the < and the > replaces the >.

0 komentar:

Poskan Komentar