HTML Block, Inline & Div
Lesson Overview: Distinguish block-level elements from inline elements and group sections cleanly with <div>.
Block vs Inline Elements
Block elements (<div>, <p>, <h1>, <section>) start on a new line and stretch to full container width. Inline elements (<span>, <a>, <strong>) stay inline with text and take only as much width as needed.
- Use <div> as a generic layout container for CSS Grid or Flexbox
- Use <span> to style a specific word or phrase inline inside text
Test Yourself With Exercises
Wrap an inline word to apply custom text color:
<p>Hello
World
!</p>
Pro Tip: Prefer semantic tags (<header>, <nav>, <main>, <article>, <footer>) over <div> wherever meaning exists.