0
0
HtmlConceptBeginner · 3 min read

What is < and > in HTML: Meaning and Usage Explained

In HTML, < and > are special codes called character entities that represent the less-than (<) and greater-than (>) symbols. They are used to show these symbols on a webpage without confusing the browser, which normally reads < and > as part of HTML tags.
⚙️

How It Works

Web browsers use the symbols < and > to mark the start and end of HTML tags, like <div>. If you want to show these symbols as normal text on a webpage, you can't just type < or > because the browser will think you're writing a tag.

To solve this, HTML uses special codes called character entities. < stands for the less-than symbol (<), and > stands for the greater-than symbol (>). When the browser sees these codes, it shows the actual symbols on the page instead of treating them as tags.

Think of it like using a secret code to tell the browser, "Show this symbol as text, not as code." This keeps your webpage safe and clear.

💻

Example

This example shows how to display the less-than and greater-than symbols on a webpage using < and >.

html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Display &lt; and &gt; Example</title>
</head>
<body>
  <p>Use &lt; to show the less-than symbol: &lt;</p>
  <p>Use &gt; to show the greater-than symbol: &gt;</p>
  <p>Example: 5 &lt; 10 and 10 &gt; 5</p>
</body>
</html>
Output
Use < to show the less-than symbol: < Use > to show the greater-than symbol: > Example: 5 < 10 and 10 > 5
🎯

When to Use

You use < and > whenever you want to show the symbols < and > as text on a webpage. This is important because typing these symbols directly can confuse the browser into thinking you are writing HTML tags.

For example, if you want to write a math comparison like "5 < 10" or show code snippets that include HTML tags, you must use these character entities. This keeps your page safe and your content clear.

In real life, this is like using quotation marks when you want to show someone’s exact words instead of your own.

Key Points

  • < and > are HTML character entities for less-than and greater-than symbols.
  • They prevent confusion between text and HTML tags in the browser.
  • Always use them when showing < or > as text in HTML.
  • They help keep your webpage safe and display content correctly.

Key Takeaways

Use < and > to safely display < and > symbols in HTML text.
These codes prevent the browser from mistaking symbols for HTML tags.
Always replace < and > with < and > when showing them as text.
They help keep your webpage content clear and error-free.