HTML Block and Inline Element
In this tutorial, the basic concepts of HTML block and Inline element are described.
Each HTML element is having a default display value based on its type. The two display values are — block and inline.
The “<div>“ tag defines a division or a block in an HTML document. Being a block-level element, it always begins with a new line and consumes the full browser width available.
This element has no required attributes, but style, class and id are common.
It is often used to group block-elements to format them with styles. See the following code:
<div style="border: 2px solid red; color: blue">
<h2>This is a header</h2>
<p>This is a paragraph.</p>
An inline element does not begin with a new line and only consumes as much width as needed. The “<span>” tag being an inline element is frequently used as a container for some text.
Like “<div>” element, this element also has no required attributes, but style, class and id are common.
This tag can be used to style parts of the text. See the code below:
<p>Too err is <span style="color: blue">human</span> !</p>