HTML Block and Inline Elements

HTML Tutorial

HTML Block and Inline Elements

In HTML, elements are mainly classified into Block-level and Inline elements.

Understanding this difference is very important for layout and styling.

 1. Block-Level Elements

Block elements:

  • Always start on a new line

  • Take full width available

  • You can set width, height, margin, padding

 Common Block Elements

<div>, <p>, <h1>–<h6>, <section>, <article>, <header>, <footer>,
<nav>, <ul>, <ol>, <li>, <table>, <form>

 Example

Output:

This is a paragraph
This is another paragraph

 2. Inline Elements

Inline elements:

  • Do not start on a new line

  • Take only required width

  • Width & height cannot be set directly

Common Inline Elements

<span>, <a>, <img>, <strong>, <em>, <b>, <i>, <label>, <input>

Example

Output:

HelloWorld

 3. Block vs Inline (Side-by-Side Example)

  • <div> takes full width
  • <span> stays in the same line

 4. div vs span (Most Important)

Feature<div><span>
TypeBlockInline
New lineYesNo
WidthFullContent only
Use caseLayoutSmall text styling

Example

 5. Inline-Block (Bonus Concept)

inline-block behaves like:

  • Inline (same line)

  • Block (width/height allowed)


 

  •  Boxes appear side by side
  • Custom size allowed

 6. Changing Element Behavior with CSS

You can change display type using CSS.

 Common Mistakes

  •  Putting block elements inside inline elements
  •  Using <br> instead of proper block elements
  •  Confusing <div> and <span> 
  •  Using inline elements for layout

 Key Points to Remember

  • Block → New line, full width

  • Inline → Same line, content width

  • <div> = block container

  • <span> = inline container

  • inline-block = best of both

You may also like...