Skip to content
Learn Netverks

Lesson

Step 20/58 34% through track

block-inline

Block and inline elements

Last reviewed May 28, 2026 Content v20260528
Track mode
iframe_html
Means
HTML preview sandbox
Reading
~2 min
Level
advanced

This lesson

This lesson teaches Block and inline elements—the ideas, syntax, and habits you need before moving on in HTML.

Without a solid grasp of Block and inline elements, you will repeat mistakes in HTML exercises and on real pages or scripts.

You will apply Block and inline elements in contexts like: Websites, hybrid apps, email templates, design systems, and CMS-driven content.

Read the lesson, edit HTML/CSS in the playground, press Run to preview, then answer the lesson MCQs. Also use the HTML reference desk when you need tag or attribute lookup.

When intermediate lessons feel comfortable and you are ready for production-style trade-offs.

CSS formatting contexts evolved beyond simple “block vs inline,” but HTML content categories still hint at default behaviors.

Classic mental model

  • Block-level elements (paragraphs, headings, lists) stack vertically and stretch to container width by default.
  • Inline-level elements (links, emphasis) flow inside lines and wrap naturally.

CSS overrides everything

display: flex on an anchor makes it generate a flex container even though anchors default to inline. Always verify rendered boxes in DevTools—not assumptions from tag names alone.

Invalid nesting consequences

  • Parsers auto-close tags when you accidentally nest blocks inside illegal inline parents.
  • Interactive content rules forbid nesting interactive elements (button inside button, etc.).

Margin collapsing preview

Adjacent vertical margins between blocks may collapse—pairs with CSS lessons. Inline boxes participate in line layout with baselines and line-height.

What trips up experienced devs anyway

  • Assuming “block/in-line” equals default display after CSS resets—everything may be flex children with different sizing rules.
  • Wrapping anchors around block cards without checking hit areas + focus outlines—fine pattern, requires styling discipline.
  • Mixing paragraphs and stray text nodes adjacent to blocks—validators flag it; parsers may hoist text unpredictably.

Important interview questions and answers

  1. Q: What makes image delivery accessible and performant?
    A: Meaningful `alt`, correct intrinsic `width`/`height`, and responsive sources (`srcset`/`sizes` or `picture`) based on viewport needs.
  2. Q: When do you use a table in HTML?
    A: Only for real tabular data, not page layout; use `th`, `scope`, and `caption` to preserve structure for assistive tech.
  3. Q: What is the role of the `head` element in production apps?
    A: It provides critical metadata like charset, viewport, title, canonical/social tags, and linked resources used by browsers and crawlers.

Interview tip: Block boxes stack; inline boxes flow with text—know default display values.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs in your browser in a sandboxed frame. Backend runners appear when this track’s profile allows them.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • What confused you about this lesson?
  • How would you explain this to a teammate in 30 seconds?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump