Block elements and Inline elements
In this blog , we will try to learn about the often most confused concept of HTML i.e block elements and inline elements and try to differentiate between the two
So what is a block element? Basically a block element can be defined as the element in HTML which consumes the entire full width available on the page and always starts in a new line i.e no two block elements can be on the same line. For example the <div> element is a block-level element.
Some of the block elements in HTML are :
Now, what is an inline element? An inline element basically only space required by itself ..so we can say that a single line may contain more than one inline element. An inline element does not start on a new line . For example This is a <span> element inside a paragraph.
To sum up
- There are two display values: block and inline
- A block-level element always starts on a new line and takes up the full width available
- An inline element does not start on a new line and it only takes up as much width as necessary
- The
<div>
element is a block-level and is often used as a container for other HTML elements - The
<span>
element is an inline container used to mark up a part of a text, or a part of a document