Believemy logo purple

<ul>

Defines an unordered list with HTML.
Believemy logo

The <ul> tag is used in HTML to define an unordered list. It allows you to group list items without a specific order, represented by the <li> tag.

 

Structure and syntax of the <ul> tag

Basic structure and syntax

Here is the basic syntax of a <ul> tag:

HTML
<ul>
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
</ul>

As we can see, it is a tag that generally groups one or more <li> tags to establish a list of unordered items.

 

Usage example

Here is a typical example of using the <ul> tag:

HTML
<ul>
  <li>Bread</li>
  <li>Milk</li>
  <li>Eggs</li>
</ul>

In this example, the <ul> tag contains a list of items (<li>) that represent the items on a shopping list.

 

Attributes

The <ul> tag accepts some classic HTML attributes such as:

  • class: to apply CSS styles to the entire list.
  • id: to identify the list uniquely.
  • style: to apply inline styles to the list.

 

Best practices

The <ul> tag should be used to group items that do not require a specific order.

If the order of the items is important, it is preferable to use an ordered list, represented by the <ol> tag.

Also, avoid nesting too many <ul> lists to avoid making the content difficult to read and maintain. 😋

 

Difference with other similar tags

  • <ol>: The <ol> tag is used to define an ordered list, where the order of the items is important. Unlike the unordered list <ul>, it is generally displayed with numbers or letters.
  • <dl>: The <dl> tag is used to create a list of definitions, where each item has an associated definition, unlike <ul> which is primarily used for list items without a specific relationship between them.

 

Browser compatibility

The <ul> tag is supported by all modern browsers.

BrowserCompatibility
ChromeYes
FirefoxYes
SafariYes
EdgeYes
Internet ExplorerYes

Discover our hTML and CSS glossary

Browse the terms and definitions most commonly used in HTML and CSS development.