HTML Block and Inline Elements
HTML Inline and Block Elements
HTML elements can be broadly categorized into one of two categories:
- Inline Elements:
<span>,<a>,<strong>,<img>etc. - Block Elements:
<p>,<div>,<h1>,<figure>etc.
HTML Inline Elements
Inline elements are displayed on the same line. They do not start on a new line and take up only as much width as their contents require. An example of an inline element is the <span> tag.
<p>This is how <span style="border: 1px solid black">span</span> works. </p>Browser Output
If we have multiple span tags, they get placed on the same line. For example,
<p> The following spans will be inline; <span style="border: 1px solid black">Span 1</span> and <span style="border: 1px solid black">Span 2</span>.</p>Browser Output
Some examples of inline elements are:
- HTML
<a>tag - HTML
<input>tag - HTML
<span>tag
Most HTML formatting tags are also inline. For example:
- HTML
<b>tag - HTML
<em>tag - HTML
<strong>tag, etc
HTML Block Elements
Block elements take up the whole horizontal space available in its container. They start on a new line and take up as much height as their contents require.
An example of a block element is the HTML Paragraph Tag.
<p style="border: 1px solid black">This is how block elements works. </p>Browser Output
If we have multiple block elements, they will each take a separate line. For example,
<p style="border: 1px solid black">Paragraphs are</p> <p style="border: 1px solid black">Block Elements.</p>Browser Output
Some frequently used Block elements are:
- HTML
<div>tag - HTML Headings
<h1>-<h6> - HTML
<p>tag, etc




Comments
Post a Comment