Explore Div Vs Span!!
Div
In an HTML document, the <div> tag defines a division or a section.
HTML elements use this as a container.
This is then styled with CSS or manipulated with JavaScript.
Div can be easily styled by using the class or id attribute.
Syntax:
<body>
<div>
<!--Other Contents-->
</div>
</body>
Example:
Span
To mark up a part of a text, or a part of a document <span> tag is used.
<span> tag is an inline container.
This is the same as div in styling and manipulating using CSS and JavaScript.
Syntax:
<body>
<p><span>Span text goes here</span> and not here</p>
</body>
(or)
<body>
<div>
<!--Other Contents-->
</div>
</body>
Example:
<div> vs <span>
<div> tag is a block-level element and <span> tag is an inline element.
The difference between a span and a div tag is that a span element is usually used for a small chunk of HTML inside a line.
<div> tag is used to group larger chunks of code.