3. Text: Headings, Paragraphs and Lists

Text is marked up with tags that describe its meaning. Headings run from h1 (most important) to h6 (least). Paragraphs use p. Use strong for important text and em for emphasis. Lists come in two types: ul for bullet points and ol for numbered steps, with each item inside an li tag.

Key points

  • Use only one h1 per page, then h2 and h3 for sub-sections.
  • <br> makes a line break and <hr> draws a line. Neither needs a closing tag.
  • Do not use headings just to make text big; use CSS for size.
  • Lists can be nested by putting a new ul inside an li.

Example: Headings, paragraphs and lists

HTML and CSS Open in editor
<h1>My Study Plan</h1>
<h2>This week</h2>
<p>I will learn <strong>HTML</strong> and <em>CSS</em>.</p>

<h3>Topics</h3>
<ul>
  <li>Text</li>
  <li>Links</li>
  <li>Layout</li>
</ul>

<h3>Steps</h3>
<ol>
  <li>Read the lesson</li>
  <li>Edit the example</li>
  <li>Press Run</li>
</ol>
Show explanation

Notice the bullet list (ul) and numbered list (ol). Try adding a new li to each.

Try it yourself

Edit the code below and press Run. The result appears in the preview underneath.

Editor
Reset Preview runs in a safe sandbox. Scripts are disabled.
PREVIEW