Depending upon the type of element, each element has a default value. Usually, the default value of most of the elements are wither block or inline.
Block-level Elements
A block element is always started with a new line and it consumes the full-width of the page available.
Please Note: <div> element is considered as the block-level element.
A Few Block Level Elements
<div>
<h1>...<h6>
<p>
<form>
Inline Elements
An inline does not starts with a new line but it takes the full page width.
A Few Inline Elements
<span>
<a>
<img>
<div> Element
<div> element is used as a container for other HTML elements.
It does not use any specific attributes, but style and class attributes are commonly used by it.
<div> element is used to add style of the content.
Syntax
<div style=”background-color:blue;color:white;padding:25px;”>
<h2>Hello</h2>
<p>Hope you are doing well</p>
</div>
<span> element
For some elements, <span> element is used as a container.
It does not use any specific attributes, but style and class attributes are commonly used by it.
To add styling to a specific part of the text, <span> element is used with CSS.
Syntax
<h1>
Hello
<spanstyle=“color:blue”>
This is an alert message.
</span>
Thanks
</h1>
Let Us Quickly Revise
<div> To define a section (block-level)
<span> To define a section (inline)