HTML:HTML Headings, Paragraphs, and Text Formatting Tags
HTML•Typography

HTML Headings, Paragraphs, and Text Formatting Tags

Learn semantic text markup to ensure proper accessibility and search engine ranking.

Syntax

<h1>Main Heading</h1> <p>Body paragraph with <strong>bold</strong> text.</p>

Parameters & Values

Key components and acceptable values for this structure:

ParameterTypeDescription
<h1> to <h6>HeadingsRepresents 6 levels of document section headings.
<p>ParagraphBlocks of body text with natural margin separation.
<code>Inline TagDisplays monospace programming code.

Ready-to-Run Code Example

Executable in Compilra

Run this complete, working example directly without installing HTML locally:

<!DOCTYPE html>
<html>
<head>
  <style>
    body { font-family: sans-serif; line-height: 1.6; padding: 15px; }
    code { background: #e2e8f0; padding: 2px 6px; border-radius: 4px; font-family: monospace; }
  </style>
</head>
<body>
  <h1>Chapter 1: Cloud Architecture</h1>
  <h2>Section 1.1: Virtual Nodes</h2>
  <p>To initialize a node, run the <code>compilra deploy</code> command in your terminal.</p>
  <p><strong>Note:</strong> Always monitor memory usage with <em>top</em>.</p>
</body>
</html>
Expected Output:
[Rendered Document Typography: H1, H2, Code Snippet, and Bold Emphasized Text]

How It Works: Step-by-Step

  • Lines 9-10: Establishes clear heading hierarchy from <h1> to <h2>.
  • Lines 11-12: Renders paragraphs with inline <code>, <strong>, and <em> elements.

Key Concepts

  • Use only one <h1> per page for optimal SEO and screen-reader accessibility.
  • <strong> conveys important semantic emphasis; <em> represents stress emphasis.

Common Mistake: Using multiple <h1> tags on a single page

Search engines and screen readers rely on a single primary <h1> to identify the page topic.

❌ Incorrect
<h1>First Title</h1>
<h1>Second Title</h1>
✅ Correct
<h1>Primary Title</h1>
<h2>Subtitle / Subsection</h2>

Related HTML Tutorials & Compiler

Run and test HTML on Compilra

Execute this code snippet with pre-supplied standard input (stdin) in Compilra’s cloud compiler.

HTML Online Compiler