Block-level And Inline Elements
Table of contents
In this article we will talk about Block level and Inline Elements and what is the difference between them.
Block Element
A block-level element always begins on a new line, and browsers add a margin (a space) before and after the element by default.
A block-level element always occupies the entire available width (stretches out to the left and right as far as possible).
<p> and <div> are two often used block components.
HTML (HyperText Markup Language) elements historically were categorized as either "block-level" elements or "inline-level" elements. Since this is a presentational characteristic it is nowadays specified by CSS in the Flow Layout. A Block-level element occupies the entire horizontal space of its parent element (container), and vertical space is equal to the height of its contents, thereby creating a "block".
Note: A block-level element always starts on a new line and takes up the full width available (stretches out to the left and right as far as it can).
Elements
<address>
<article>
<aside>
<blockquote>
<canvas>
<dd>
<div>
<dl>
<dt>
<fieldset>
<figcaption>
<figure>
<footer>
<form>
<h1>-<h6>
<header>
<hr>
<li>
<main>
<nav>
<noscript>
<ol>
<p>
<pre>
<section>
<table>
<tfoot>
<ul>
<video>
Inline Element
A line break is not used to begin an inline element.
An inline element only uses the space that is required.
An inline element cannot contain a block-level element.
An inline element does not start on a new line.
An inline element only takes up as much width as necessary.
This is an <span> element inside a paragraph.
Here are the inline elements in HTML:
**Note:** An inline element cannot contain a block-level element!
Subscribe to my newsletter
Read articles from Arun kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by