Horje

Tips (Total 15)


# Tips-1) What is HTML Lists

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

An unordered HTML list:

An ordered HTML list:

  1. First item
  2. Second item
  3. Third item
  4. Fourth item

 

Full Example of HTML Lists

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h2>An Unordered HTML List</h2>

<ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>  

<h2>An Ordered HTML List</h2>

<ol>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol> 

</body>
</html>

Output should be:

Full Example of HTML Lists

# Tips-2) How to create HTML Lists

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

Full Example of HTML Lists

Here is given example
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h2>An Unordered HTML List</h2>

<ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>  

<h2>An Ordered HTML List</h2>

<ol>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol> 

</body>
</html>

Output should be:

Full Example of HTML Lists

# Tips-3) How to create Unordered HTML List

An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.

Full Example of Unordered HTML List

The list items will be marked with bullets (small black circles) by default:
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h2>An unordered HTML list</h2>

<ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>  

</body>
</html>

Output should be:

Full Example of Unordered HTML List

# Tips-4) How to create Ordered HTML List

An ordered list starts with the <ol> tag. Each list item starts with the <li> tag.

Full Example of Ordered HTML List

The list items will be marked with numbers by default:
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h2>An ordered HTML list</h2>

<ol>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>  

</body>
</html>

Output should be:

Full Example of Ordered HTML List

# Tips-5) How to create HTML Description Lists

HTML also supports description lists.

A description list is a list of terms, with a description of each term.

Full Example of HTML Description Lists

The <dl> tag defines the description list, the <dt> tag defines the term (name), and the <dd> tag describes each term:
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h2>A Description List</h2>

<dl>
  <dt>Coffee</dt>
  <dd>- black hot drink</dd>
  <dt>Milk</dt>
  <dd>- white cold drink</dd>
</dl>

</body>
</html>

Output should be:

Full Example of HTML Description Lists

# Tips-6) How to create 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:

Value Description
disc Sets the list item marker to a bullet (default)
circle Sets the list item marker to a circle
square Sets the list item marker to a square
none The list items will not be marked

Example - Disc

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h2>Unordered List with Disc Bullets</h2>

<ul style="list-style-type:disc;">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>  

</body>
</html>

Output should be:

Example - Disc

Example - Circle

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h2>Unordered List with Circle Bullets</h2>

<ul style="list-style-type:circle;">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>  

</body>
</html>

Output should be:

Example - Circle

Example - Square

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h2>Unordered List with Square Bullets</h2>

<ul style="list-style-type:square;">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>

</body>
</html>

Output should be:

Example - Square

Example - None

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h2>Unordered List without Bullets</h2>

<ul style="list-style-type:none;">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>  

</body>
</html>

Output should be:

Example - None

# Tips-7) How to create Nested HTML Lists

Lists can be nested (list inside list):

Full Example of Nested HTML Lists

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

<h2>A Nested List</h2>
<p>Lists can be nested (list inside list):</p>

<ul>
  <li>Coffee</li>
  <li>Tea
    <ul>
      <li>Black tea</li>
      <li>Green tea</li>
    </ul>
  </li>
  <li>Milk</li>
</ul>

</body>
</html>

Output should be:

Full Example of Nested HTML Lists

# Tips-8) How to create HTML Horizontal List with CSS

Full Example of HTML Horizontal List with CSS

One popular way is to style a list horizontally, to create a navigation menu:
index.html
Example: HTML
<!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>

<h2>Navigation Menu</h2>
<p>In this example, we use CSS to style the list horizontally, to create a navigation menu:</p>

<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>

Output should be:

Full Example of HTML Horizontal List with CSS

# Tips-9) How to create Ordered HTML List - The Type Attribute

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

Type Description
type="1" The list items will be numbered with numbers (default)
type="A" The list items will be numbered with uppercase letters
type="a" The list items will be numbered with lowercase letters
type="I" The list items will be numbered with uppercase roman numbers
type="i" The list items will be numbered with lowercase roman numbers

 

Basic Example of Ordered HTML List - The Type Attribute

The HTML <ol> tag defines an ordered list. An ordered list can be numerical or alphabetical.
index.html
Example: HTML
 <ol>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol> 

Output should be:

Basic Example of Ordered HTML List - The Type Attribute

# Tips-10) How to create HTML Ordered HTML List Number

type="1" The list items will be numbered with numbers (default)

Full Example of HTML Ordered HTML List Number

Ordered Number Define <ol type="1"> Tag
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h2>Ordered List with Numbers</h2>

<ol type="1">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>  

</body>
</html>

Output should be:

Full Example of HTML Ordered HTML List Number

# Tips-11) How to create HTML Ordered Uppercase Letters

type="A" The list items will be numbered with uppercase letters

Full Example of HTML Ordered Uppercase Letters

Ordered Uppercase Letters Define <ol type="A"> Tag
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h2>Ordered List with Letters</h2>

<ol type="A">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>  

</body>
</html>

Output should be:

Full Example of HTML Ordered Uppercase Letters

# Tips-12) How to create HTML Ordered Lowercase Letters

type="a" The list items will be numbered with lowercase letters

Full Example of HTML Ordered Lowercase Letters

Ordered Lowercase Letters Define <ol type="a"> Tag
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h2>Ordered List with Lowercase Letters</h2>

<ol type="a">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>  

</body>
</html>

Output should be:

Full Example of HTML Ordered Lowercase Letters

# Tips-13) How to create HTML Ordered Uppercase Roman Numbers

type="I" The list items will be numbered with uppercase roman numbers

Full Example of HTML Ordered Uppercase Roman Numbers

Ordered List with Roman Numbers define <ol type="I"> Tag
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h2>Ordered List with Roman Numbers</h2>

<ol type="I">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>  

</body>
</html>

Output should be:

Full Example of HTML Ordered Uppercase Roman Numbers

# Tips-14) How to create HTML Ordered Lowercase Roman

type="i" The list items will be numbered with lowercase roman numbers

Full Example of HTML Ordered Lowercase Roman

HTML Ordered Lowercase Roman defines <ol type="i">
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h2>Ordered List with Lowercase Roman Numbers</h2>

<ol type="i">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>  

</body>
</html>

Output should be:

Full Example of HTML Ordered Lowercase Roman

# Tips-15) How to create HTML 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:

Full Example of HTML Control List Counting

By default, an ordered list will start counting from 1. Use the start attribute to start counting from a specified number:
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h2>The start attribute</h2>
<p>By default, an ordered list will start counting from 1. Use the start attribute to start counting from a specified number:</p>

<ol start="50">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>

<ol type="I" start="50">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>

</body>
</html>

Output should be:

Full Example of HTML Control List Counting