HTML tagLists

<ul>

A bulleted list in which the order of the items doesn’t matter.

Display
block
Closing tag
Required
Permitted content
<li> elements (<script> and <template> are also allowed)
On this page

Example

#
HTML
<h3>What you’ll learn in the HTML course</h3>
<ul>
  <li>build a page structure from headings and paragraphs</li>
  <li>insert images, links, and lists</li>
  <li>create contact forms</li>
  <li>publish a page on the internet</li>
</ul>
Preview

Definition and usage

#

The <ul> element (from unordered list) creates an unordered list. You write each item in a separate <li> element, and the browser puts a bullet in front of it. Use <ul> when swapping the order of the items doesn’t change the meaning: a list of a course’s benefits, the ingredients of a recipe, the tags under an article.

If order matters (instruction steps, a ranking), use <ol>. When the items are “name and description” pairs, <dl> is a better fit. Lists can be nested, but a sublist always goes inside an <li> element, never directly into the <ul>.

Most navigation menus are built on lists as well. Screen readers announce that a list is starting and give the number of its items, which helps users judge the length of a menu. You change the bullet shape in CSS with the list-style property, and you style the bullets themselves with the ::marker pseudo-element.

Syntax

#
Syntax
<ul>
  <li>…</li>
  <li>…</li>
</ul>

Attributes

#

This element has no attributes of its own. It supports the global attributes, such as class, id and hidden.

More examples

#
A nested list
HTML
<ul>
  <li>Frontend
    <ul>
      <li>HTML</li>
      <li>CSS</li>
      <li>JavaScript</li>
    </ul>
  </li>
  <li>Backend
    <ul>
      <li>Python</li>
      <li>Node.js</li>
    </ul>
  </li>
</ul>
Preview

Default CSS

#

Most browsers display this element with these default styles:

CSS
ul {
  display: block;
  list-style-type: disc;
  margin-block: 1em;
  padding-inline-start: 40px;
}
ul ul {
  list-style-type: circle;
  margin-block: 0;
}

Browser support

#

Widely available

Works in all modern browsers, phones included. You can use it without worry.

  • Chrome
  • Edge
  • Firefox
  • Safari

Good practices

#
  • The only direct child of <ul> can be <li>. Put a heading, paragraph, or sublist inside the <li>.
  • When you remove the bullets with list-style: none, VoiceOver in Safari may stop announcing the list. You can restore that with the role="list" attribute.
  • The type attribute on <ul> (for example type="square") is obsolete. Set the bullet shape in CSS: list-style-type: square.

Related entries

#

Practise it in lessons

#

Spotted a mistake or missing an example? Write to us.