html
/

HTML Block vs Inline Elements

Last Sync: Today

On this page

11
0%
5 min read
Remaining
5 minleft

Click any section to jump — progress syncs automatically

html

HTML Block vs Inline Elements

What are Block and Inline Elements?

HTML elements are categorized into block-level and inline elements based on how they behave in a layout.

Block-Level Elements

Block elements take up the full width available and start on a new line.

HTMLRead-only
1
<div>This is a block element</div>
<p>This is a paragraph</p>

Common Block Elements

ElementDescription
<div>Generic container
<p>Paragraph
<h1>-<h6>Headings
<section>Section of content
<article>Independent content

Inline Elements

Inline elements do not start on a new line and only take up as much width as necessary.

HTMLRead-only
1
<span>This is inline</span>
<a href="#">Link</a>

Common Inline Elements

ElementDescription
<span>Generic inline container
<a>Anchor/link
<strong>Bold text
<em>Italic text
<img>Image

Key Differences

FeatureBlockInline
Line BreakStarts new lineDoes not start new line
WidthFull widthContent width
Height/Width ControlYesLimited
Examples<div>, <p><span>, <a>

Changing Display with CSS

CSSRead-only
1
div {
  display: inline;
}

span {
  display: block;
}

Inline-Block Elements

Inline-block elements behave like inline elements but allow width and height control.

CSSRead-only
1
span {
  display: inline-block;
  width: 100px;
  height: 50px;
}

Best Practices

  • Use block elements for layout structure
  • Use inline elements for text styling
  • Avoid misusing display properties unnecessarily
  • Use semantic elements where possible

Common Mistakes

  • Using inline elements for layout
  • Ignoring display behavior
  • Overriding display incorrectly
  • Mixing block and inline improperly

Conclusion

Understanding block and inline elements is essential for building proper layouts and styling web pages effectively.

Try it yourself

<div>Block</div>
<span>Inline</span>

Test Your Knowledge

Q1
of 3

Which is a block element?

A
<span>
B
<a>
C
<div>
D
<img>
Q2
of 3

Which is an inline element?

A
<p>
B
<div>
C
<span>
D
<section>
Q3
of 3

Which CSS property changes display?

A
position
B
display
C
float
D
align

Frequently Asked Questions

What is a block element?

An element that takes full width and starts on a new line.

What is an inline element?

An element that takes only required width and stays in line.

What is inline-block?

It behaves like inline but allows width and height control.

Previous

html quotations

Next

html file paths

Related Content

Need help?

Explore our comprehensive docs or start a chat with our tech experts.