What is the difference between DIV, SPAN and paragraph tag in HTML?
All three are used to hold content, but they are different.
| Tag | Type | Use |
|---|---|---|
<div> | Block | Generic container to group sections and for layout |
<span> | Inline | Generic container to style a small part of text |
<p> | Block | A paragraph of text, with a meaning |
<div class="card">
<p>My favourite colour is <span style="color:red">red</span>.</p>
</div>
Output in the browser
My favourite colour is red.
div and span have no meaning of their own, while p tells that the text is a paragraph. See HTML Div and Span.
Learn more about the similar topics:
| Tutorials |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |