Most pages are mainly text. HTML gives text structure through headings and paragraphs, and it marks the importance of words through formatting tags.

Headings

HTML has six levels of headings, from <h1> to <h6>. The <h1> heading is the most important and is normally used once, for the title of the page. The <h2> headings divide the page into main sections, and <h3> headings divide those sections further. Headings should follow the outline of the content, without skipping levels. Search engines and screen readers use the headings to understand the page, so a heading must never be used just to make text larger.

Paragraphs and Line Breaks

The <p> element holds one paragraph. Browsers add space before and after it. A browser ignores extra spaces and blank lines in the source code, and joins them into a single space. The <br> element forces a line break inside a paragraph, and <hr> draws a horizontal line across the page. The <pre> element is different: it keeps spaces and line breaks exactly as typed, and shows the text in a fixed-width font, which suits computer code.

Definition: Block element. An element that starts on a new line and takes the full available width.

Definition: Inline element. An element that stays within a line of text and takes only the width it needs.

Headings and paragraphs are block elements. Formatting tags such as <strong> are inline elements, and they sit inside a line of text.

Formatting Tags

Formatting tags mark words inside a paragraph. Table 1.3 lists the common ones. The tags <strong> and <em> carry meaning: strong importance and emphasis. The tags <b> and <i> only change the look, so they should be used rarely.

Table 1.3: Common text formatting tags

Tag Meaning Usual display
<strong> Strong importance Bold
<em> Emphasis Italic
<mark> Highlighted text Yellow background
<sub> Subscript Small and lowered
<sup> Superscript Small and raised
<blockquote> Long quotation Indented block

Putting It Together

Example 1.3: An article with headings and formatting

<h1>Web Basics</h1>
<h2>What is HTML?</h2>
<p>HTML is <strong>easy</strong> to learn and <em>very</em> useful.</p>
<p>Water is H<sub>2</sub>O and area is measured in m<sup>2</sup>.</p>
<hr>
<blockquote>The web is for everyone.</blockquote>

Output in the browser:

Common mistakes

  • Using an h3 heading only because it looks smaller than an h2.
  • Typing several spaces or blank lines and expecting the browser to show them.
  • Using br tags to create space between paragraphs instead of using separate p elements.
  • Using b and i where strong and em are meant.

Key takeaways

  • Headings run from h1 to h6 and should follow the outline of the content.
  • A p element makes a paragraph. The br element breaks a line, and pre keeps spacing.
  • Block elements start on a new line, and inline elements stay within a line.
  • Use strong and em to give meaning, and sub and sup for small raised or lowered text.

Practice questions

  1. How many h1 headings should a page normally have?
  2. Which element keeps spaces and line breaks exactly as typed?
  3. Is the strong element a block or an inline element?

Answers to the practice questions

  1. One, for the title of the page.
  2. The pre element.
  3. Inline.

Sources

  • Official BCA syllabus (NEP 2025 scheme), Web Application Development, course code 25BCA405DS04, Unit I