Advertisement

HTML Block, Inline & Div

Previous Lesson 107 of 114 Next
Advertisement
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

Block Container vs Inline Span (Editable — type & Run)

Advertisement

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.
Advertisement