HTML Unordered Lists
In this page:
Creating a Basic Unordered List
<ul> wraps the whole list, and each individual item goes inside its own <li> (list item) tag. Browsers render each <li> with a bullet point by default, visually signaling that these items form a related but unordered group.
Note: Every piece of content in a list must be wrapped in its own <li>; text placed directly inside <ul> without an <li> wrapper is invalid.
Warning: Forgetting the closing </li> tag on an item can cause unpredictable nesting behavior in some browsers.
Example: Creating a Basic Unordered List
<ul>
<li>Milk</li>
<li>Bread</li>
</ul>
Nesting Sublists
A sublist is created by placing an entire new <ul> element inside a parent <li>, not after it -- this makes the sublist a genuine child of that specific item, and browsers automatically indent it and often switch the bullet style to visually distinguish nesting depth.
Note: Always place the nested ul fully inside the parent li's opening and closing tags to preserve correct nesting.
Warning: Placing a nested ul as a sibling after </li> instead of inside it breaks the semantic parent-child relationship of the sublist.
Example: Nesting Sublists
<ul>
<li>Fruits
<ul>
<li>Apple</li>
</ul>
</li>
</ul>
Changing the Bullet Style
list-style-type controls the marker shape shown before each item -- disc (a filled circle, the default), circle (a hollow circle), or square (a filled square) -- letting you visually differentiate nested list levels or match a design's aesthetic.
Note: Use different list-style-type values across nesting levels to help readers visually distinguish how deep a sublist goes.
Warning: Changing list-style-type purely for decoration on a navigation menu still leaves the underlying semantic list structure intact for screen readers.
Example: Changing the Bullet Style
<ul style="list-style-type: square;">
<li>Item one</li>
<li>Item two</li>
</ul>
Removing Bullets for Navigation Menus
list-style: none removes the bullet marker entirely, which is the standard technique used to turn a semantically correct <ul> into a horizontal or vertical navigation menu, keeping the accessible list structure while visually looking nothing like a bulleted list.
Note: Prefer a real ul styled with list-style: none for navigation menus over a series of plain divs, to keep the semantic list structure for assistive technology.
Warning: Removing default margin and padding is usually needed alongside list-style: none, since browsers still apply default list indentation even without visible bullets.
Example: Removing Bullets for Navigation Menus
<ul style="list-style: none;">
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
</ul>
Using a Custom Image as a Marker
list-style-image lets you replace the default bullet shape with a small custom image, useful for a branded checklist look, though modern CSS often achieves more consistent, scalable results using a ::marker pseudo-element or a background-image on the li instead.
Note: Prefer sizing your marker image carefully or use the ::marker pseudo-element for more reliable, consistent cross-browser positioning than list-style-image alone.
Warning: list-style-image gives limited control over the marker's exact size and position compared to styling ::marker or using a background-image trick.
Example: Using a Custom Image as a Marker
<ul style="list-style-image: url('check.png');">
<li>Completed step</li>
</ul>
- Placing text or other content directly inside <ul> without wrapping it in an <li> element, which is invalid HTML.
- Nesting a new <ul> as a sibling of <li> instead of inside it, which breaks the visual and semantic nesting of a sublist.
- Using list-style: none purely to remove bullets from a navigation menu without considering that this can affect how some screen readers announce list semantics.
- <ul> creates an unordered (bulleted) list, and every item inside it must be wrapped in its own <li> element.
- A nested sublist must be placed entirely inside its parent <li>, not as a sibling after it.
- list-style-type controls the bullet marker shape (disc, circle, square), and list-style: none removes markers entirely.
<ul> and <li> have been part of HTML since its earliest versions and are supported in every browser.
Chapter Quiz — Complete all 26 topics to unlock
0/26 topics done
Complete these topics first:
- HTML Favicon
- HTML Page Title
- HTML Tables
- HTML Lists
- HTML Block & Inline
- HTML Comments
- HTML Colors
- HTML CSS
- HTML Links
- HTML Images
- HTML RGB Colors
- HTML HEX Colors
- HTML HSL Colors
- HTML Link Colors
- HTML Link Bookmarks
- HTML Background Images
- HTML Table Borders
- HTML Table Sizes
- HTML Table Headers
- HTML Table Padding & Spacing
- HTML Colspan & Rowspan
- HTML Table Styling
- HTML Table Colgroup
- HTML Unordered Lists
- HTML Ordered Lists
- HTML Other Lists / Description Lists