Class 3 Exam  >  Class 3 Notes  >  HTML for Junior Classes  >  HTML Lists & Block & Inline Elements

HTML Lists & Block & Inline Elements | HTML for Junior Classes - Class 3 PDF Download

HTML lists allow web developers to group a set of related items in lists.
Example

HTML Lists & Block & Inline Elements | HTML for Junior Classes - Class 3Unordered HTML List


An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.
The list items will be marked with bullets (small black circles) by default:
Example

<ul>

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ul>

Ordered HTML List

An ordered list starts with the <ol> tag. Each list item starts with the <li> tag.
The list items will be marked with numbers by default:
Example

<ol>

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ol>

HTML Description Lists

HTML also supports description lists.
A description list is a list of terms, with a description of each term.
The <dl> tag defines the description list, the <dt> tag defines the term (name), and the <dd> tag describes each term:

Example


<dl>

  <dt>Coffee</dt>

  <dd>- black hot drink</dd>

  <dt>Milk</dt>

  <dd>- white cold drink</dd>

</dl>

HTML Unordered Lists

The HTML <ul> tag defines an unordered (bulleted) list.

Unordered HTML List

An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.
The list items will be marked with bullets (small black circles) by default:

Example

<ul>

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ul>

Unordered HTML List - Choose List Item Marker

The CSS list-style-type property is used to define the style of the list item marker. It can have one of the following values:
HTML Lists & Block & Inline Elements | HTML for Junior Classes - Class 3

Example - Disc

<ul style="list-style-type:disc;">

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ul>

Example - Circle

<ul style="list-style-type:circle;">

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ul>

Example - Square

<ul style="list-style-type:square;">

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ul>

Example - None

<ul style="list-style-type:none;">

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ul>

Nested HTML Lists

Lists can be nested (list inside list):

Example

<ul>

  <li>Coffee</li>

  <li>Tea

    <ul>

      <li>Black tea</li>

      <li>Green tea</li>

    </ul>

  </li>

  <li>Milk</li>

</ul>

Note: A list item (<li>) can contain a new list, and other HTML elements, like images and links, etc.

Horizontal List with CSS

HTML lists can be styled in many different ways with CSS.
One popular way is to style a list horizontally, to create a navigation menu:

Example

<!DOCTYPE html>

<html>

<head>

<style>

ul {

  list-style-type: none;

  margin: 0;

  padding: 0;

  overflow: hidden;

  background-color: #333333;

}


li {

  float: left;

}


li a {

  display: block;

  color: white;

  text-align: center;

  padding: 16px;

  text-decoration: none;

}


li a:hover {

  background-color: #111111;

}

</style>

</head>

<body>


<ul>

  <li><a href="#home">Home</a></li>

  <li><a href="#news">News</a></li>

  <li><a href="#contact">Contact</a></li>

  <li><a href="#about">About</a></li>

</ul>


</body>

</html>

HTML Ordered Lists

The HTML <ol> tag defines an ordered list. An ordered list can be numerical or alphabetical.

Ordered HTML List

An ordered list starts with the <ol> tag. Each list item starts with the <li> tag.
The list items will be marked with numbers by default:

Example

<ol>

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ol>

Ordered HTML List - The Type Attribute

The type attribute of the <ol> tag, defines the type of the list item marker:

Ordered HTML List

An ordered list starts with the <ol> tag. Each list item starts with the <li> tag.
The list items will be marked with numbers by default:

Example

<ol>

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ol>

Ordered HTML List - The Type Attribute

The type attribute of the <ol> tag, defines the type of the list item marker:

HTML Lists & Block & Inline Elements | HTML for Junior Classes - Class 3

Numbers:

<ol type="1">

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ol>

Uppercase Letters:

<ol type="A">

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ol>

Lowercase Letters:

<ol type="a">

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ol>

Uppercase Roman Numbers:

<ol type="I">

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ol>

Lowercase Roman Numbers:

<ol type="i">

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ol>

Control List Counting

By default, an ordered list will start counting from 1. If you want to start counting from a specified number, you can use the start attribute:

Example

<ol start="50">

  <li>Coffee</li>

  <li>Tea</li>

  <li>Milk</li>

</ol>

Nested HTML Lists

Lists can be nested (list inside list):

Example

<ol>

  <li>Coffee</li>

  <li>Tea

    <ol>

      <li>Black tea</li>

      <li>Green tea</li>

    </ol>

  </li>

  <li>Milk</li>

</ol>

Note: A list item (<li>) can contain a new list, and other HTML elements, like images and links, etc.

HTML Other Lists

HTML also supports description lists.

HTML Description Lists

A description list is a list of terms, with a description of each term.
The <dl> tag defines the description list, the <dt> tag defines the term (name), and the <dd> tag describes each term:

Example

<dl>

  <dt>Coffee</dt>

  <dd>- black hot drink</dd>

  <dt>Milk</dt>

  <dd>- white cold drink</dd>

</dl>

HTML Block and Inline Elements

Every HTML element has a default display value, depending on what type of element it is.
There are two display values: block and inline.

Block-level Elements

A block-level element always starts on a new line, and the browsers automatically add some space (a margin) before and after the element.
A block-level element always takes up the full width available (stretches out to the left and right as far as it can).
Two commonly used block elements are: <p> and <div>.

  • The <p> element defines a paragraph in an HTML document.
  • The <div> element defines a division or a section in 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>

Here are the block-level elements in HTML:
HTML Lists & Block & Inline Elements | HTML for Junior Classes - Class 3

Inline Elements

  • An inline element does not start on a new line.
  • An inline element only takes up as much width as necessary.
  • This is HTML Lists & Block & Inline Elements | HTML for Junior Classes - Class 3 a paragraph.

Example

<span>Hello World</span>

Here are the inline elements in HTML:

HTML Lists & Block & Inline Elements | HTML for Junior Classes - Class 3

Note: An inline element cannot contain a block-level element!

The <div> Element

  • The <div> element is often used as a container for other HTML elements.
  • The <div> element has no required attributes, but style, class and id are common.
  • When used together with CSS, the <div> element can be used to style blocks of content:

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 is an inline container used to mark up a part of a text, or a part of a document.
  • The <span> element has no required attributes, but style, class and id are common.
  • When used together with CSS, the <span> element can be used to style parts of the text:

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>

The document HTML Lists & Block & Inline Elements | HTML for Junior Classes - Class 3 is a part of the Class 3 Course HTML for Junior Classes.
All you need of Class 3 at this link: Class 3
14 videos|31 docs|24 tests

Top Courses for Class 3

14 videos|31 docs|24 tests
Download as PDF
Explore Courses for Class 3 exam

Top Courses for Class 3

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Semester Notes

,

study material

,

Viva Questions

,

MCQs

,

mock tests for examination

,

Sample Paper

,

practice quizzes

,

Important questions

,

video lectures

,

shortcuts and tricks

,

Free

,

pdf

,

Exam

,

past year papers

,

Summary

,

HTML Lists & Block & Inline Elements | HTML for Junior Classes - Class 3

,

HTML Lists & Block & Inline Elements | HTML for Junior Classes - Class 3

,

Extra Questions

,

ppt

,

HTML Lists & Block & Inline Elements | HTML for Junior Classes - Class 3

,

Previous Year Questions with Solutions

,

Objective type Questions

;