The Purpose of HTML Entities
HTML entities are specific character sequences that start with an ampersand ( ) and end with a semicolon (;). They are used in web development to display characters that are either reserved in HTML syntax or cannot be typed directly using a standard keyboard.
For example, the characters `<` and `>` are reserved in HTML because they define the boundaries of tags (like `<div>`). If a developer writes `if (x < y)` directly in an HTML file, the browser will interpret `<y` as an unclosed HTML tag, breaking the page layout. To display these characters as text, they must be written as the HTML entities ` lt;` and ` gt;`.
Additionally, entities allow developers to write non-ASCII symbols, math operators, and typographic marks in source files without worrying about file character encoding issues.