What is the difference between inline and block elements in HTML?
A block element starts on a new line and takes the full width. An inline element stays in the same line and takes only as much width as its content.
| Point | Block | Inline |
|---|---|---|
| New line | Yes | No |
| Width | Full width | Only the content |
| Examples | div, p, h1, ul, table | span, a, strong, img |
<p>Block one</p>
<p>Block two</p>
<span>Inline one</span> <span>Inline two</span>
Output in the browser
Block one
Block two
Inline one Inline two
See HTML Block and Inline Elements.
Learn more about the similar topics:
| Tutorials |
|---|
| List of common HTML Tags |
| HTML Elements and Tags |
| HTML Attributes |
| HTML Block and Inline Elements |
| HTML Div and Span |
| HTML Class and ID |
| Exercises & Assignments |
|---|
| No Content Found. |