Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

What is the difference between block and inline elements in HTML?

user-image
Question added by amr rashad , United Arab Emirates , Host Sailor
Date Posted: 2018/01/06
Joseph Salugta
by Joseph Salugta , Web Developer , Emerson Electric

Block-level elements always start on a new line and takes up the full width available (stretches out to the left and right as far as it can) of a web page, while inline elements do not start on a new line and only takes up as much width as necessary on a section of a web page.

block tages like <p></p> ... IF we write this tage (for examble) 2 timer and see the page ,we will find the 2 paragraphes under eath other

inline tages like <img > ... if we put 2 images , we will find the two behind each other

 

 

anil kumar
by anil kumar , Web Designer , Footprints Education Pvt. Ltd

A block-level element occupies the entire space of its parent element (container), thereby creating a "block."

Inline elements are those which only occupy the space bounded by the tags defining the element, instead of breaking the flow of the content.

Mahmoud azzazi
by Mahmoud azzazi , Senior Full Stack Developer , Udawi

Block Level Elements

So what is a block-level element? A block-level element is an HTML element that begins a new line on a web page and extends the full width of the available horizontal space of its parent element. It creates large blocks of content like paragraphs or page divisions. In fact, most HTML elements are block-level elements.

 

Block-level elements are used within the HTML document's body. They can contain inline elements, as well as other block-level elements.

     

Inline Elements

In contrast to a block-level element, an inline element:

 

 

  • Can begin within a line
  • Does not start a new line
  • Its width only extends as far as it is defined by its tags. 

Sairath N
by Sairath N , Sr.Software Engineer , SPACE

HTML is made up of various elements that act as the building blocks of web pages. Each of these elements falls into one of two categories - either a block-level elements or an inline elements.

A block-level element is an HTML element that begins a new line on a Web page and extends the full width of the available horizontal space of its parent element.

It creates large blocks of content like paragraphs or page divisions. In fact, most HTML elements are block-level elements.

Example <div><p>

An inline element can:

  • Begin within a line
  • Does not start a new line
  • Its width only extends as far as it is defined by its tags.

Example: <span><strong>

 

 

Deleted user
by Deleted user

Every HTML element has a default display value depending on what type of element it is.The default display value for most elements is block or inline.

A block-level element always starts on a new line and takes up the full width available .

The <div> element is a block-level element.

Block level elements in HTML:

<address> <article> <aside> <blockquote> <canvas> <dd> <div> <dl> <dt> 

<fieldset><figcaption><figure><footer><form><h1>-<h6><header><hr><li>

<main><nav><noscript><ol><output><p><pre><section><table><tfoot>

<ul> <video>.

Inline Elements 

An inline element does not start on a new line and only takes up as much width as necessary.

This is an inline <span> element.

Inline elements in HTML:

<a> <abbr> <acronym> <b> <bdo> <big> <br> <button> <cite> <code>

<dfn> <em> <i> <img> <input> <kbd> <label> <map> <object> <q>

<samp> <script> <select> <small> <span> <strong> <sub> <sup>

<textarea> <time> <tt> <var>.

 

 

More Questions Like This