What is the difference between div and span?

html

<div> Element

<div> element is one of the famous block elements. It defines a section or division in an HTML document.<div> is a container element that is used to group the content, so that it can be styled easily using class or id attribute.
1
2
3
4
<div style="background-color:lightgrey">
  <h3> I am a heading </h3>
  <p> I am a paragraph </p>
</div>

<span> Elment

<span> element is one of the famous inline elements. It is an inline container element that is used to group inline elements in the HTML document. The grouped inline elements can then be easily styled using class or id attribute.

1
2
3
<p>You are reading about
  <span style="color:red"> Inline and Block Elements.</span>
</p>

Share and support us

Share on social media and help us reach more people