Course Content
HTML Introduction
0/1
HTML Editors
0/1
HTML Basic Tags
0/1
HTML Elements
0/1
HTML Attributes
0/1
HTML Headings
0/1
HTML Paragraph
0/1
HTML Text Formatting
0/1
HTML Meta Tags
0/1
HTML Quotations
0/1
HTML Comments
0/1
HTML Images
0/1
HTML Background
0/1
HTML Colors
0/1
HTML Lists
0/1
HTML Tables
0/1
HTML Forms
0/1
HTML Spell Check
0/1
HTML Media
0/1
HTML Marquees
0/1
HTML CSS
0/1
HTML Links
0/1
HTML Block & Inline
0/1
HTML Classes
0/1
HTML Id
0/1
HTML I frames
0/1
HTML Java script
0/1
HTML File paths
0/1
HTML Layout
0/1
HTML Responsive
0/1
HTML Computer Code
0/1
HTML Tutorial
About Lesson

HTML Block & Inline

In this tutorial, we will learn about Block and Inline elements in HTML with the help of examples.


Block & Inline Elements

Every HTML element can be categorized into two categories :

  1. Block-level Element
  2. Inline Element

All the HTML element has a default display value, depending on what type of element it is.


Block-level Elements

A block-level element always starts a new line. Block-level elements take up a line break before and after them.
They take up the full width available.

The List of all Block-level Elements

<address> <article> <aside> <blockquote>
<canvas> <dd> <dl> <dt>
<div> <fieldset> <figure> <figcaption>
<footer> <form> <h1-h6> <header>
<hr> <li> <main> <nav>
<noscript> <ol> <p> <pre>
<section> <table> <tfoot> <ul>
<video>

Inline Element

The inline elements always appear within the sentences. Inline elements do not start on a new line.
They only take up as much width as necessary.

The List of all Inline Elements

<a> <abbr> <acronym> <b>
<bdo> <big> <br> <button>
<cite> <code> <dfn> <em>
<i> <img> <input> <kbd>
<label> <map> <object> <output>
<q> <samp> <script> <select>
<small> <span> <strong> <sub>
<sup> <textarea> <time> <tt>
<var>

HTML Elements Grouping

There are two important tags which are used to group various other HTML tags:

  1. <div> Element
  2. <span> Element

<div> Element

The <div> element is block-level element which plays a significant role in grouping various other HTML elements. It is used as a container for other HTML elements.
The <div> element doesn’t add or change the content in the HTML document. The <div> element doesn’t have any required attributes, but style , class , and id are common.

Note : When CSS is used with HTML, the <div> element can be used to style block of the content.

Example :

<!DOCTYPE html>
<html>
  <head>
    <title>div Element</title>
  </head>
  <body>
    <div style = "background-color : yellow;">
      <h2>Washington D.C.</h2>
      <p>Washington D.C. is the capital city of USA.</p>
    </div>
  </body>
</html>

Output

Washington D.C.

Washington D.C. is the capital city of USA.


<span> Element

The <span> element is an inline element. It is used to grouping inline elements in an HTML document. The <span> element is an inline container and used to mark up a part of a document.
The <span> element doesn’t add or change the content in the HTML document. The <span> element doesn’t have any required attributes, but style, class, and id are common.

Note : When CSS is used with HTML, the <span> element can be used to style block of the content.

Example :

<!DOCTYPE html>
<html>
  <head>
    <title>span Element</title>
  </head>
  <body>
      <h2>New York</h2>
      <p>Paris is the <span style = "color : blue;">capital city
of France.</span></p>
  </body>
</html>

Output

New York

Paris is the capital city of France.

error: Content is protected !!