HTML Tutorial

HTML Entities

Entities print reserved characters: less-than, ampersand, copyright, and non-breaking space.

Characters the markup already uses

HTML source is text, but a few characters are not ordinary text. The parser treats< as “a tag starts here” and & as “an entity starts here.” If you want those characters to appear on the page, you write an entity — a short name the parser turns into the real character after it has finished reading tags.

An entity starts with & and ends with ;. Named entities such as&lt; are easy to remember. Numeric entities such as &#169; work too. Beginners can stay with the named set in the table below.

Why a raw less-than breaks the parser

Suppose you want the sentence “If score is 5 < 10, you pass.” If you type a real< into the paragraph, the browser does not see a comparison. It sees the start of a tag named “ 10, you pass.” That is not a valid tag, so the rest of the paragraph can vanish, wrap oddly, or swallow following markup.

Example — this source is wrong

<p>If the score is 5 < 10, you pass.</p>
<p>Tom & Jerry play piano.</p>

The first line starts a malformed tag at < 10. The second line starts an entity at& that never ends, so Jerry can be eaten or shown incorrectly. Always encode these two in text: less-than as &lt;, ampersand as &amp;.

Greater-than (>) is safer in text, but write &gt; anyway so the file is obvious to the next reader. In attribute values, quote the value and still encode& and, when needed, the quote character itself.

Source versus rendered

The live preview at /html/try shows the rendered page, not the entity names. In the editor you type &copy;. On the page you see ©. That gap is the whole point of entities.

Example — correct source

<p>If the score is 5 &lt; 10, you pass.</p>
<p>Tom &amp; Jerry play piano.</p>
<p>5 &gt; 2 is also true.</p>
<p>He said &quot;open early.&quot;</p>
<p>Copyright &copy; 2026 Eastside Bakery.</p>
<p>Keep&nbsp;this&nbsp;together on one line.</p>

The same file paints as:

If the score is 5 < 10, you pass.

Tom & Jerry play piano.

5 > 2 is also true.

He said "open early."

Copyright © 2026 Eastside Bakery.

Keep this together on one line.

The entities you will type daily

EntityRenders asUse it for
&lt;<Less-than in text or examples of HTML
&gt;>Greater-than
&amp;&A real ampersand: company names, query strings in text
&nbsp;a non-breaking spaceA space that will not wrap to the next line
&copy;©The copyright sign
&quot;"A double quote inside a double-quoted attribute

To show HTML tags in a tutorial, you encode both brackets: &lt;p&gt; renders as<p>. Never put a raw <p> in the middle of a sentence unless you intend to start a paragraph element.

Non-breaking space

A normal space is a wrap opportunity. The browser may split “10 km” so that “10” ends one line and “km” starts the next. &nbsp; is a space that refuses to break. Use it for units, initials, and short phrases you want to keep on one line — not as a way to indent paragraphs.

Example

<p>The loaf weighs 900&nbsp;g.</p>
<p>Meet at 14&nbsp;Harbor Lane.</p>
<p>Chapter&nbsp;4 is the forms track.</p>

Do not chain dozens of &nbsp; entities to push text sideways. That is layout, and layout belongs in CSS. The entity is for “do not split this pair.”

Quotes, copyright, and attributes

Inside element content, a straight " is usually fine. Inside an attribute that is already wrapped in double quotes, a raw " would end the attribute early. Write&quot; or switch the attribute to single quotes.

  • &copy; is © — typical in a footer: Copyright &copy; 2026.
  • &quot; is " — typical in title="He said &quot;hello&quot;".
  • You can also write curly quotes as characters if the file is UTF-8. Entities are required only when the character would confuse the parser.

Ampersand is the one people forget in URLs pasted as text: a=1&amp;b=2 in a paragraph. In a real href you still encode it: href="search?a=1&amp;b=2".

What to remember

  • A raw < in text starts a tag. Write &lt; instead.
  • A raw & starts an entity. Write &amp; for a real ampersand.
  • &nbsp; is a space that will not wrap. &copy; is ©. &quot; is a double quote.
  • The editor shows source. The preview shows characters. Both views are correct.

Next: the character set. UTF-8 is how the file stores José, Søren, and every other letter the web uses.

Worked examples

The short listings above show the tag in isolation. These pages use the same markup on documents you would actually publish: a lab report, a clinic form, a timetable, a weather card.

HTML does not calculate. It names the pieces so a browser, a screen reader, and a search engine can tell a heading from a paragraph. The numbers below are classroom values — the same Ohm, pH, and pulse figures as the C track — now sitting in real page structure.

Preview them in the HTML editor at /html/try. Change a heading or a number and watch the page, not a print log.

Maths

Less-than in a sentence

The characters <, >, and & start markup. To show them as text you write &lt;, &gt;, and &amp;. Otherwise the browser thinks a tag has begun.

nbsp is a non-breaking space: 12 kg stays on one line. Use it for number and unit, not for indenting paragraphs.

pH < 7 means acidic

Example

<p>Acidic if pH &lt; 7</p>
<p>Toast &amp; tomato</p>
<p>Mass 12&nbsp;kg</p>

Physics

Degree and micro

UTF-8 can store ° and µ directly if charset is set. Entities still help when a keyboard cannot type them. Either way, the visitor should see 20 °C, not 20 C.

Example

<p>20 &deg;C is 293.15 K</p>
<p>Earth’s field is about 50 &micro;T</p>

FAQ: HTML Entities

Common questions about this page.

What is the StudyGrid HTML tutorial?

The StudyGrid HTML tutorial is a full beginner track: tags, headings, links, images, tables, layout, forms, and media. Each chapter has copy-and-run examples.

Should I run html entities examples locally for better learning?

Yes. Use the browser editor on StudyGrid for a quick check, then Download the example and run it on your computer. Local runs show real errors and the real toolchain, which is one of the fastest ways to learn html entities in this HTML HTML lesson (HTML Entities).

Is the HTML editor the same as Try Python?

No. Try HTML is a live page preview at /html/try. Try Python stays at /try and runs Python. HTML lessons never open the Python editor.

Do I need to install anything to learn HTML?

No. Open a chapter, click Try it in HTML, and the page preview updates in the browser. You can also download a .html file and open it locally.

Where should I start the HTML tutorial?

Start at HTML Intro, then Basic, Elements, and Attributes. After the first document, continue to headings, links, and forms. Use Next at the bottom of each chapter.

Is the HTML tutorial free?

Yes. The HTML studio on StudyGrid (studygrid.in) is free: dashboard, chapters, and the live preview editor.