HTML <ul> Tag

The HTML<ul> tag is used for specifying an unordered list, which groups a collection of items having no numerical order. If you change the order of list items, the meaning will not change.

Each element of an unordered list is declared inside the <li> tag.

The <ul> tag is a block-level element, and occupies all available horizontal space. Its height depends on the content within the container. An unordered list is typically rendered as a bulleted list.

The <ol> tag is used to create an ordered list.

Syntax

The <ul> tag comes in pairs. The content is written between opening (<ul>) and closing (</ul>) tags.

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <ul>
      <li>List item</li>
      <li>List item</li>
      <li>List item</li>
    </ul>
  </body>
</html>

Result

You can use type attribute to change the default bullet style for the list items.

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <ul type="circle">
      <li>List item </li>
      <li>List item</li>
      <li>List item</li>
    </ul>
    <ul type="square">
      <li>List item</li>
      <li>List item</li>
      <li>List item</li>
    </ul>
  </body>
</html>

Result

You can also use CSS list-style-type or list-style-image property to define the type of a list item element.

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <h2>Examples of unordered lists:</h2>
    <ul style="list-style-type: square">
      <li>Cold Drinks</li>
      <li>Hot Drinks</li>
      <li>Ice-Creams</li>
    </ul>
    <ul style="list-style-type: disc">
      <li>Coca-Cola</li>
      <li>Fanta</li>
      <li>Ice Tea</li>
    </ul>
    <ul style="list-style-type: circle">
      <li>Coca-Cola</li>
      <li>Fanta</li>
      <li>Ice Tea</li>
    </ul>
  </body>
</html>

Result

Attributes

Attribute Value Description
compact compact Specifies that the list should be rendered in a compact style.
Not supported in HTML 5.
type disc
square
circle
Sets the type of marker.
Not supported in HTML 5.

The <ul> tag also supports the Global attributes and the Event Attributes.

Browser support