Skip to main content
SNP-2025-0007
Home / Code Snippets / SNP-2025-0007
SNP-2025-0007  ·  CODE SNIPPET

Text Tags: Blocks, headings and Inlines a quick start ✍

Tech · Published: 2026-01-15 · Debasis Bhattacharjee
Developer Snippet Cookbook and Pocket Reference PDF cover
Developer Reference Kit · PDF

Want a clean, checked snippet book?

  • 146 copy-ready snippets: JavaScript, Python, SQL, Bash & Linux, Git, PHP, CSS & HTML, Docker
  • Each one says when to use it, how it works and what to watch out for
  • 12 one-page cheat sheets for Git, Linux, cron, HTTP, SQL, regex and more
  • Code was checked with real tools, and the SQL was run against a sample database

146 snippets and 12 cheat sheets, each snippet with a "watch out" note.

$3.99 one-time · instant email delivery
2,000 Interview Questions & Answers cover
Also available: 2,000 Interview Questions & Answers $7.99 The questions developers get asked in interviews, across 89 topics, with short answers, in-depth explanations, common mistakes and follow-ups. See what's inside →

The material stays free to read online. This is the organised, offline, print-ready PDF edition. Secure payment by PayPal; your personal download link is emailed after payment is confirmed. Digital product, no shipping.

01
Problem Statement & Scenario
The Problem

Block Elements vs. Inline Elements

Before delving into specific tags, it's essential to grasp the distinction between block and inline elements.

  • Block Elements: These include tags such as <p>, <div>, heading elements (<h1> to <h6>), lists, and list items. When positioned on a page, block elements do not permit other elements to be visualized next to them. They typically create a new "block" or section in the layout.
  • Inline Elements: On the other hand, inline elements, like the <span> tag, can sit next to other inline elements. Unlike block elements, inline elements allow content to flow alongside them. Moreover, inline elements can be contained within block elements, but the reverse is not true.

The <p> Tag and Inline Elements

Let's explore the <p> tag, which defines a paragraph of text and is considered a block element:

<p>Some text</p>

The block aspect of the <p> tag becomes evident when the tag is placed on its own line. Within a <p> tag, you can include inline elements, such as the <span> tag:

<p>A part of the text <span>and here another part</span></p>

Heading Tags (<h1> to <h6>)

HTML provides six heading tags, ranging from <h1> (most important) to <h6> (least important). Typically, a page features one <h1> element, serving as the page title. Subsequent headings, like <h2> to <h6>, represent varying levels of importance. Browsers render <h1> larger by default, gradually decreasing the size as the heading level increases:

<h1>h1</h1>
<h2>h2</h2>
<h3>h3</h3>
<h4>h4</h4>
<h5>h5</h5>
<h6>h6</h6>
<p>Paragraph</p>

All heading tags are block elements and cannot contain other block elements. However, they can include inline elements, like <span> or <strong>.

Understanding the distinction between block and inline elements, as well as the specific attributes of tags like <p> and heading tags, is foundational to creating well-structured HTML documents. As you continue your journey in web development, these insights will prove invaluable.

1-on-1 Technical Mentorship

Want to master snippets like this?

Debasis Bhattacharjee offers direct mentorship sessions for developers looking to level up their code quality, architecture decisions, and production engineering skills. Two decades of real-world experience — no theory, just craft.