← Learning Hub
Beginner

Headings and Paragraphs

HTML has six levels of headings, from <h1> (most important) to <h6> (least important). Use them like the headings in a book: one main title, then sections and sub-sections.

Paragraphs use <p>. The browser adds space around each paragraph automatically. Extra spaces and line breaks you type inside the code are ignored.

Headings give your page an outline, like a newspaper: a big headline, then section titles, then smaller sub-titles. Readers skim headings to find what they want, and so do search engines like Google. Usually a page has one <h1>, a few <h2>s, and <h3>s inside those. Don't skip levels (h1 straight to h4).

Because the browser ignores extra spaces and line breaks in your code, you can format your HTML neatly without changing what visitors see. To start a new paragraph, use a new <p>; for a line break inside a paragraph (like an address), use <br>.

Example
<!DOCTYPE html>
<html>
  <body>
    <h1>Monsoon Recipes</h1>
    <h2>Snacks</h2>
    <h3>Onion Pakoda</h3>
    <p>Crispy fritters made with gram flour and sliced onion.</p>
    <h3>Corn Chaat</h3>
    <p>Boiled corn tossed with lemon, salt and chilli.</p>
    <hr>
    <p>A horizontal rule (hr) separates sections.</p>
  </body>
</html>
▶ Try it yourself
Search engines and screen readers use headings to understand your page. Do not pick a heading just because its text is big; choose it by importance and style it with CSS.
Key points
  • Use <h1> to <h6> by importance, not by size.
  • One <h1> per page is a good rule.
  • Paragraphs use <p>; extra spaces in code are ignored.

📝 Test yourself

1. Which is the most important heading?
2. What happens to extra spaces typed inside a paragraph?
3. Which tag draws a horizontal line?
<>