HTML <ul> Tag

Beginner
6 min read
Updated: Nov 2026
4 examples
Live preview

Definition and Usage

The <ul> element represents an unordered list — a group of items where the order does not change the meaning. Browsers usually show a bullet for each <li>.

Use <ol> when order matters (steps, rankings). Style markers with CSS list-style-type, not the old HTML type attribute. Nest lists by placing a new <ul> or <ol> inside an <li>.

Baseline · Widely available.

Not deprecated. Stable across browsers since about July 2015 (and much earlier in practice).

Deprecated attributes.

Do not use type or compact on <ul>. Prefer CSS list-style-type and line-height.

Choosing ul vs ol.

Shuffle the items in your head. If the meaning changes, use <ol>; if not, use <ul>.

HTML Syntax

syntax.html
<ul> <li>item</li></ul>

Both start and end tags are required. Direct children should be <li> (plus optional <script> / <template>). Nested lists belong inside an <li>, not as siblings of <li>.

Attributes

Prefer global attributes plus CSS for styling. These element-specific attributes are deprecated — shown only so you recognize them in old markup:

AttributeDescriptionTry it
typeDeprecated. Old bullet style (disc, circle, square). Use CSS list-style-type insteadTry it
compactDeprecated. Hint for a tighter list. Use CSS (for example line-height: 80%) insteadTry it

Global Attributes

The <ul> tag also supports the Global Attributes in HTML.

Live Preview

Change the CSS bullet style on a real <ul>. This is the modern replacement for the deprecated type attribute.

list-style-type

Applied as list-style-type on the list — not the HTML type attribute.

Shopping list
  • Milk
  • Eggs
  • Bread

list-style-type: disc

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Basic Unordered List

Wrap each item in <li> inside one <ul>.

HTML
<ul>
  <li>Apple</li>
  <li>Orange</li>
  <li>Banana</li>
</ul>
Try It Yourself

How It Works

  1. Open <ul> to start an unordered list.
  2. Add one <li> per item (Apple, Orange, Banana).
  3. Close the list with </ul>.
  4. The browser draws bullets because order is not meaningful here.

Example 2 — Nested Lists

Put a child <ul> inside an <li> to build a hierarchy.

HTML
<ul>
  <li>Fruits
    <ul>
      <li>Apple</li>
      <li>Orange</li>
    </ul>
  </li>
  <li>Vegetables
    <ul>
      <li>Carrot</li>
      <li>Spinach</li>
    </ul>
  </li>
</ul>
Try It Yourself

How It Works

  1. Write the parent item text inside an <li>.
  2. Nest another <ul> inside that same <li>.
  3. Add child <li> items for the sublist.
  4. Close the parent <li> after the nested list ends.

Example 3 — Ordered List Inside ul

Mix list types when a sub-sequence needs numbers.

HTML
<ul>
  <li>Pack a bag</li>
  <li>Morning checklist
    <ol>
      <li>Brush teeth</li>
      <li>Eat breakfast</li>
      <li>Lock the door</li>
    </ol>
  </li>
  <li>Leave on time</li>
</ul>
Try It Yourself

How It Works

  1. Keep the outer list as <ul> when top-level order is flexible.
  2. Put an <ol> inside one <li> for ordered steps.
  3. Numbered items stay meaningful even if you reorder other bullets.
  4. Never nest <ol> as a direct child of <ul> — always wrap it in <li>.

Example 4 — Style Bullets with CSS

Control markers with list-style-type instead of the deprecated type attribute.

HTML
<style>
  .circle-list { list-style-type: circle; }
</style>

<ul class="circle-list">
  <li>Milk</li>
  <li>Eggs</li>
  <li>Bread</li>
</ul>
Try It Yourself

How It Works

  1. Give the list a class (here circle-list).
  2. Set list-style-type to circle (or disc, square, none).
  3. Keep HTML free of type so styling stays in CSS.
  4. Reuse the class anywhere you need the same bullet look.

Edge Cases & Pitfalls

Most ul mistakes are wrong nesting, using lists for layout, or relying on deprecated attributes.

nesting

Nest lists inside li, not beside it

A <ul> or <ol> must not be a direct child of another list. Place the nested list inside the parent <li>.

meaning

Do not use ul for ordered steps

If reordering items changes the meaning, use <ol>. Bullets imply no required sequence.

deprecated

Avoid type and compact

Both are obsolete on <ul>. Style markers and spacing with CSS for consistent, maintainable results.

layout

Lists are not a layout tool

Use <ul> for real lists (nav, features, ingredients). For generic containers, prefer <div> or semantic sections.

a11y

Keep the list role intact

Implicit role is list. Do not strip list semantics with CSS alone when items are still a list — screen readers rely on correct markup.

Browser Support

The <ul> element is core HTML in every modern browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

<ul>

Widely available since about July 2015 (and far earlier in practice). Chrome, Firefox, Safari, Edge, and Opera all support unordered lists and nesting.

98% Global support (approx.)
Google Chrome All modern
Full support
Mozilla Firefox All modern
Full support
Apple Safari All modern
Full support
Microsoft Edge All modern
Full support
Opera All modern
Full support
Samsung Internet All modern
Full support
Internet Explorer All
Full support
<ul> Widely supported

Bottom line: Safe for production lists. Prefer CSS for bullet style, and nest child lists inside li elements.

Key Takeaways

  • Role: <ul> groups items when order does not change the meaning.
  • Children: put content in <li>; nest other lists inside an <li>.
  • Styling: use CSS list-style-type — not deprecated type/compact.
  • Sibling: ordered sequences → <ol>; name/value groups → <dl>.

One line: use <ul> + <li> for unordered items, nest inside <li>, and style bullets with CSS.

Default CSS Settings

Typical user-agent styling for ul (exact values can vary slightly by browser):

default.css
ul {
  display: block;
  list-style-type: disc;
  margin-block: 1em;
  padding-inline-start: 40px;
}

Nested lists often switch markers (for example circle, then square). Override with list-style-type or the list-style shorthand.

Frequently Asked Questions

The ul element groups items whose order does not change the meaning — usually shown as a bulleted list. Put each item in an li.
ul is for unordered collections (bullets). ol is for ordered sequences (numbers or letters) where changing the order would change the meaning.
Yes. Place a nested ul or ol inside an li of the parent list. Do not put a ul or ol as a direct child of another ul or ol.
No. type and compact are deprecated. Style bullets with the CSS list-style-type (or list-style) property instead.
Zero or more li elements, plus script and template. List items hold the visible content; script/template are for advanced cases.
No. It is Baseline and widely available. Only the old type and compact attributes on ul are deprecated.

Next: var

Mark variables and placeholders with the HTML var element.

var tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

14 people found this page helpful