What is the difference between HTML DIV and SPAN tag?

 <div> is a block level tag which plays a big role in grouping various other HTML tags and applying CSS on group of elements.
 <span> is an inline element and it can be used to group inline-elements in an HTML document. This tag also does not provide any visual change on the block but has meaning  when it is used with CSS.

 

Ex:

<div style=”color:red”>
<h4>This is first group</h4>
<p>Following is a list of vegetables</p>
<ul>
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ul>
</div>
<div style=”color:green”>
<h4>This is second group</h4>
<p>Following is a list of fruits</p>
<ul>
<li>Apple</li>
<li>Banana</li>
<li>Mango</li>
<li>Strawberry</li>
</ul>
</div>

Leave a Reply