Friday, 15 November 2024

Special Characters and Symbols in HTML

HTML entities are special codes used in HTML to represent characters that have a specific meaning in HTML or are not easily typeable on a keyboard. They allow you to display reserved characters, symbols, or characters that might not be included in the standard keyboard.

HTML entities are written with & followed by a name or a number and then a semicolon (;).

 

They come in two main forms.

 

1.   Named Entities: Use a descriptive name to represent the character.

Example: &lt; for < (less than), &gt; for > (greater than), &amp; for & (ampersand) &copy; fir © (Copyright sign) .

 

2.   Numeric Entities: Use a numeric code to represent the character.

Example: &#60; for < (less than), &#62; for > (greater than), &#38; for & (ampersand).

 

html-entities.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HTML Entities Example</title>
</head>
<body>
    <p>Using named entities: &lt;div&gt; &amp; &copy;</p>
    <p>Using numeric entities: &#60;div&#62; &#38; &#169;</p>

    &lt;&lt;&lt; &copy; Harikrishna &gt;&gt;&gt;
</body>
</html>

 


 

References

https://www.w3schools.com/charsets/ref_html_entities_4.asp

https://developer.mozilla.org/en-US/docs/Glossary/Character_reference


Previous                                                    Next                                                    Home

No comments:

Post a Comment