crus4

crus4

HTML Entities


In HTML, reserved characters must be replaced with character entities. We can also replace some characters that are not present on our keyboard with the help of entities.

Some characters like less than (<) or greater than (>) signs are reserved in HTML. If you use these signs in your text, the browser might mix them with tags. Therefore we use character entities to display reserved characters in an HTML document.

In an example below this is how character entity looks like:

Example

&entity_name ;
or
&#entity_number ; 

It’s better to use entity number instead of entity name, because browsers do not support all entity names.

Note:- Don’t forget to add semicolon at the end of entity name or number.

How to use an entity in an HTML

In an example below let’s see how you can use entity name and number in HTML:

Example

<!DOCTYPE html>
<html>
<body> 
<h2> HTML Entity Example </h2>
<!--by name -->
<p> This is a less than sign: &lt; </p> 
<!-- by number -->
<p> This is also a less than sign : &#60; </p> 
</body>
</html> 

Some Commonly Used HTML Character Entities

Description Entity Name Entity NumberResult
Less than&lt;&#60;<
Greater than&gt;&#62;>
Single quotation mark &apos;&#39;
Double quotation mark&quot;&#34;
ampersand&amp;&#38;&
non-breaking space&nbsp;&160;
cent&cent;&#162;¢
pound &pound;&3163;£
yen&yen;&#165;¥
euro&euro;&#8364;
copyright&copy;&#169;©
registered trademark&reg;&#174;®


Related Posts

HTML Computer Code

HTML Responsive

Add CSS to HTML

HTML Entities – crus4

3 thoughts on “HTML Entities – crus4

Leave a Reply

Your email address will not be published.