HTML Block and Inline
Tables taught you how cells share a grid. Now zoom out to the whole page: every element also follows a default display habit in normal flow. Beginners meet two big families — block and inline. Block boxes usually start on a new line and stretch across the available width. Inline pieces nest inside a line of text. Meaning tags still matter (p, a, strong); this lesson is about how those tags sit beside each other before you restyle them with CSS.
What “flow” means here
Flow is the browser’s default packing order when you have not yet written layout CSS. A paragraph is a block: the next sibling starts below it. A link is inline: it continues in the same sentence. Headings, lists, div, and table behave like block boxes by default. strong, em, span, and a behave like inline pieces. Replaced elements such as img are often described as inline-level in beginner docs even though their box model has special rules — treat them as “sit in the line” until you study CSS in depth.
Direct answer
Block-level elements typically begin on a new line and take the available width (p, div, h1–h6, ul, ol, section, table). Inline elements sit inside a line of text (a, strong, em, span, code). You will later change habits with CSS display, but first memorize the defaults so markup surprises you less. Choose tags for meaning first; use display knowledge to predict stacking versus in-line nesting.
📊 Common defaults
| Category | Examples | Flow habit |
|---|---|---|
| Block | p, div, h1–h6, ul, ol, section, table | New line, full available width (typical) |
| Inline | a, strong, em, span, code | Continues inside the text line |
Block boxes with inline pieces inside
A paragraph is a block container. Inside it, links and emphasis stay inline so the sentence still reads as one line (until it wraps naturally). A following div opens a new block box beneath. That mix — block outside, inline inside — is the most common beginner pattern on content pages.
Block paragraph with inline pieces
html<p>
Read the <a href="guide.html">guide</a> and note the
<strong>important</strong> words before you continue.
</p>
<div>This div is a separate block box on its own line.</div>
Reading the paragraph sample
- The
pis a block: it owns a full paragraph box aandstrongstay in the reading line as inline pieces- The
divafter the paragraph starts on a new line as another block - You did not need CSS yet to see stacking versus nesting
- Href values and wording can change; the display habit stays the same
- If the link jumps to a new line alone, check whether you accidentally closed the
pearly
div versus span for grouping
Both div and span are generic wrappers with little built-in meaning. The practical difference for beginners is default display: div is block, span is inline. Wrap a whole section-like chunk that should break onto its own lines with div (or, better when you know them, semantic sectioning tags). Wrap a short phrase inside a sentence with span when you only need a hook for style or script later — not a new block.
div versus span contrast
html<p>Price: <span class="note">includes tax</span> today only.</p>
<div class="note">This whole note sits on its own block line.</div>
Reading the div/span sample
spankeeps “includes tax” inside the paragraph linedivforces the second note onto its own block row- Class names are optional hooks; the display difference is the lesson
- Prefer real semantic tags when they fit (
strong,em,a) before empty wrappers - Later CSS can make a
spanlook blocky — defaults still matter for unstyled markup - Do not replace every semantic tag with
div/spanjust because they are flexible
CSS can change display later
Browsers ship with default style sheets. Your CSS may set display: block, inline, inline-block, or modern layout modes like flex and grid. That is why a tutorial can show span { display: block; } and suddenly a phrase stacks like a paragraph. Learn defaults first so you recognize when CSS is overriding them. This course’s next sessions (div, classes, id) build hooks you will style; block versus inline is the map underneath.
Practice in your editor
- Write two
pelements with different sentences and confirm they stack. - Put two
alinks inside one paragraph and confirm they stay in the line. - Wrap one short phrase in
spanand the same phrase indivon a second try — compare the layout. - Add
strongaround one word inside a paragraph; confirm it does not force a new block line. - Temporarily wrap an entire paragraph’s text in an extra
divinside theponly if your practice file allows it — or place adivbeside thep— and note the extra block break. - Write one sentence under your demo listing three block tags and three inline tags you used.
- Optional: open DevTools and glance at the computed
displayvalue forpversusa.
Easy mistakes
- Using
divfor every tiny phrase that should bespanor a semantic tag - Expecting
strongorato always start on a new line (they are inline by default) - Forgetting that CSS
displaycan override these defaults later - Choosing tags only for looks (“I want a new line”) instead of meaning plus default flow
- Nesting block elements inside
pincorrectly (invalid or surprising markup in many cases) - Treating
div/spanas the only tools and ignoringp, lists, and headings you already know
Summary
- Block defaults: new line, available width (
p,div, headings, lists,table) - Inline defaults: continue inside the text line (
a,strong,em,span) - Mix them: block containers often hold inline pieces
- Prefer
spanfor tiny in-line hooks; prefer meaningful tags when they fit - CSS may change display later — memorize defaults first
- Next: deeper practice with
divas a block container in the following session
🧠 Test Your Knowledge
Test Your Knowledge
Challenge yourself with this interactive quiz and see how well you understand the topic
📝 Instructions
- Read each question carefully
- Select the best answer for each question
- You can retake the quiz as many times as you want
- Your progress will be shown at the top