How to Add Less Than and Greater Than Symbols in HTML
To add less than and greater than symbols in HTML, use the character entities
< for less than (<) and > for greater than (>). These entities ensure the symbols display correctly without being mistaken for HTML tags.Syntax
In HTML, the less than and greater than symbols are reserved for tags. To show them as text, use these character entities:
<for the less than symbol (<)>for the greater than symbol (>)
These codes start with an ampersand (&), followed by a short name, and end with a semicolon (;).
text
< for less than symbol > for greater than symbol
Output
< for less than symbol
> for greater than symbol
Example
This example shows how to display less than and greater than symbols in a paragraph without confusing the browser:
html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Less Than and Greater Than Example</title> </head> <body> <p>Use < to mean less than and > to mean greater than.</p> <p>Example: 5 < 10 and 10 > 5.</p> </body> </html>
Output
Use < to mean less than and > to mean greater than.
Example: 5 < 10 and 10 > 5.
Common Pitfalls
Many beginners try to write the symbols directly like < or > in HTML. This causes errors because the browser thinks they are tags.
Always use < and > to show these symbols as text.
html
<!-- Wrong way: --> <p>5 < 10 and 10 > 5</p> <!-- Right way: --> <p>5 < 10 and 10 > 5</p>
Output
5 < 10 and 10 > 5
Quick Reference
| Symbol | HTML Entity | Description |
|---|---|---|
| < | < | Less than symbol |
| > | > | Greater than symbol |
Key Takeaways
Use < and > to display less than and greater than symbols in HTML.
Writing < or > directly can break your HTML because they are reserved for tags.
Character entities start with & and end with ; to show special symbols safely.
Always test your HTML in a browser to confirm symbols display correctly.