What Is "&#" in HTML?

In HTML, an ampersand and hash together (i.e. &#) is used to specify an HTML entity with a numeric character code (either in decimal or hexadecimal form). It has the following syntax:


Where entity_number can be a decimal or hexadecimal number that represents a character's code point in Unicode/UCS. After the entity's numeric code, a semi-colon (;) follows to mark the end of the HTML entity code.

For example, the Euro symbol () is represented in Unicode as 20AC in hexadecimal and as 8364 in decimal. For HTML to parse and interpret the character correctly, you would write it as an HTML entity like so:

<!-- euro symbol in decimal -->
<!-- euro symbol in hexadecimal -->

Please note that hexadecimal characters need to be prefixed with x (which is just a way of indicating to the parser that the subsequent characters need to be interpreted as hexadecimal).

This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.