Learning HTML | HTML characters entities

Sabtu, 24 Desember 2011

Once we have learned previously about attributes HTML, now we will be learning to how to display the special characters in HTML.
Some special characters such as characters <, have special meaning in HTML (as a sign of HTML tags), so you will not be able to use it as a text in terms of direct written as <in your HTML code.
To display a smaller sign (<) in HTML, you need to learn about HTML Character Entities.

character entities

Some characters have special meaning in HTML, such as a smaller sign (<) that defines the beginning of an HTML tags. If we want the browser to display the smaller sign (<), we must insert character entities in our HTML code.
Character entities has three components: a sign and (&), entity name or a # followed by the entity number and end with a semicolon (;).

To display a smaller sign in the HTML page, then we must write: &lt, or &#60;
The advantage of using a name than a number is that the name easier to remember. The drawback is that not all browsers support the names of the new entity, however, almost all browsers support the standard entity name.
Note: the entities are case sensitive.

Spaces sequentially

Character entities that may be most often you are wearing is white space.
HTML will eliminate the spaces in your HTML text. If you write 10 spaces in your HTML code, then the HTML will remove 9 spaces. Well, to add space to your HTML document, use the character entities


Some character entities that are often used:
Results Explanation entities Name entities Number
Spaces &nbsp; &#160;
< less than &lt; &#60;
>  more than &gt; &#62;
" quotes &quot; &#34;
'
single quotation
&apos; (does not apply in IE) &#39;
& And &amp; &#38;

Some of the comments that have requested that this tutorial is coupled with an example for clarity. Well, here are examples to clarify what is meant by character entities.

His case is very easy anyway. We do already know, if it uses the name HTML tag, right? One example is the tag to bold letters.

Now imagine if one day you're asked to write a tutorial  HTML and happen to be writing about the HTML tag that works to menebelkan letters. For example, you want the following lines appear in the tutorial you (note, you want to tag and appear in that line).

To thicken bold letters as the word is, you need <b> tag and </ b>

Well, think about, how to write this simple bari without character entities. Can not? For example, you write like this:


To thicken the letters as the word <b> bold </ b>,
     you need tag <b>  and </ b>


What happened? The browser will display the following sentence:

To thicken bold letters as the word is, you need a tag and

What's the difference? Yes ... <b> tag and </ b> does not appear, instead, the word and will appear in bold. To make the tag <b> and </ b> may appear, you need character entities, so you have to write HTML code like this:

To thicken the letters as the word <b> bold </ b>,
     you need &lt;b&gt; and &lt;/b&gt;


Note, the sign <I replace with character entities &lt, while a> I replace with &gt;.

Lhah ... tuh add more questions in the comments. Gini question, continue our way of showing how dunks &gt let that out instead of>.

Easy wrote, we can use the &amp in front of it to escape the & sign, so you can write like this &amp; &gt; (no space between &amp; and &gt;.. I had to write use spaces, since it is unlikely I will leave no spaces. )

Easy right? Ok, hopefully this example can increase your understanding of what is meant by this character entities.

Well, you've pretty much learning HTML now. So, do not forget to come back to learndesignweb.blogspot.com place where the best tutorials available for free.

1 komentar:

Posting Komentar

 
© Copyright 2010-2011 web design Web Design.
learning HTML Learning PHP | Published by create PHP | Sport News Blogger.com.