![]() |
VOOZH | about |
HTML elements are either block-level, which structure the layout and span full width (like <div> or <p>), or inline, which styles content within blocks without breaking the flow (like <span> or <a>). This distinction covers 80–90% of common HTML usage.
Example: Here, we illustrate the use of the block-level element(Div) and the inline element(<a>).
Code Overview:
In the above example, we have used the <div> tag that always starts in a new line & captures the full width available. We have also used the inline element anchor tag <a> that is used to provide a link to a text that doesn't start in a new line & captures only the space around the element.
A block-level element always starts on a new line and stretches out to the left and right as far as it can i.e, it occupies the whole horizontal space of its parent element & the height is equal to the content's height.
The <div> element is used as a container for other HTML elements. It has no required attributes. Style, class, and id are the commonly used attributes.
Syntax:
<div>GFG</div>Example: The below code illustrates the implementation of <div> tag.
Output:
An inline element is the opposite of the block-level element. It does not start on a new line and takes up only the necessary width ie., it only occupies the space bounded by the tags defining the HTML element, instead of breaking the flow of the content.
The <span> tag is used as a container for text. It has no required attributes. Style, class, and id are the commonly used attributes.
Syntax:
<span>GFG</span>
Example: The below code illustrates the implementation of <span> tag.