Curriculum
Course: HTML Basic
Login

Curriculum

HTML Basic

HTML Introduction

0/1

HTML Editors

0/1

HTML Elements

0/1

HTML Attributes

0/1

HTML Headings

0/1

HTML Paragraphs

0/1

HTML Styles

0/1

HTML Formatting

0/1

HTML Quotation

0/1

HTML Comments

0/1

HTML Colors

0/1

HTML Favicon

0/1

HTML Page Title

0/1

HTML Block and Inline

0/1

HTML Iframes

0/1

HTML Java Script

0/1

HTML File Paths

0/1

HTML - The Head Element

0/1

HTML Style Guide

0/1

HTML Entities

0/1

HTML Symbols

0/1
Text lesson

HTML Block and Inline

Each HTML element inherently possesses a default display value, which varies based on the type of element it is.The two predominant display values are block and inline.

Block-level Elements

A block-level element consistently begins on a fresh line, with browsers automatically including space (margin) before and after the element.

A block-level element invariably occupies the entire available width, extending to both the left and right edges.

Two frequently utilized block elements are: <p> for defining paragraphs in an HTML document, and <div> for delineating divisions or sections within an HTML document.

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

Example

<p>Hello World</p>
<div>Hello World</div>

Below are the block-level elements in HTML:

Inline Elements

An inline element does not initiate a new line.

An inline element occupies only the width required for its content.

This is a <span> element inside a paragraph.

Example

<span>Hello World</span>

These are the inline elements in HTML:

Please note: An inline element is unable to encompass a block-level element!

The <div> Element

The <div> element is frequently employed as a wrapper for additional HTML elements.

Although the <div> element doesn’t mandate specific attributes, style, class, and id are commonly utilized.

When utilized in conjunction with CSS, the <div> element serves as a tool for styling content blocks.

Example

<div style=”background-color:black;color:white;padding:20px;”>
  <h2>London</h2>
  <p>London is the capital city of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.</p>
</div>

The <span> Element

The <span> element serves as an inline container utilized to annotate a segment of text or a portion of a document.

While the <span> element doesn’t necessitate specific attributes, style, class, and id are frequently applied.

When paired with CSS, the <span> element facilitates the styling of text segments.

Example

<p>My mother has <span style=”color:blue;font-weight:bold;”>blue</span> eyes and my father has <span style=”color:darkolivegreen;font-weight:bold;”>dark green</span> eyes.</p>

Summary of the Chapter

  • A block-level element initiates a new line and occupies the entire available width.
  • An inline element does not initiate a new line and only occupies the necessary width.
  • The <div> element, functioning as a block-level container, is commonly employed to encapsulate other HTML elements.
  • The <span> element, serving as an inline container, is utilized to annotate specific text portions or sections within a document.

 

Click to Learn