#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
HTML Fundamentals

HTML Lists

HTML lists group related items together, and browsers display them with bullets, numbers or indented terms. There are three kinds: unordered lists for items where order does not matter, ordered lists for steps or rankings, and description lists for term-and-definition pairs. Navigation menus, recipe steps, feature lists and glossaries are all built with them.

Unordered lists

An unordered list uses the ul element, and each item goes inside an li element. Browsers show a bullet before each item by default. Use it when shuffling the items would not change the meaning, such as a list of skills or a shopping list.

Ordered lists and their attributes

An ordered list uses ol and numbers its items automatically. Insert a new item in the middle and the numbers update by themselves. A few attributes control the numbering:

  • type changes the marker: 1 (default), A, a, I or i.
  • start sets the first number, for example start="5" to continue a list after a break.
  • reversed counts downward, useful for a top-ten countdown.
  • value on a single li sets that item's number, and later items continue from it.

Description lists

A description list uses dl, with dt for each term and dd for its description. A term can have several descriptions, and several terms can share one. It suits glossaries, FAQs and key-value details like product specifications.

<h2>Morning routine</h2>
<ol>
  <li>Drink a glass of water</li>
  <li>Stretch for ten minutes</li>
  <li>Plan the day
    <ul>
      <li>Check calendar</li>
      <li>Pick three priorities</li>
    </ul>
  </li>
</ol>

<h2>Glossary</h2>
<dl>
  <dt>HTML</dt>
  <dd>The markup language that structures web content.</dd>
  <dt>CSS</dt>
  <dd>The language that controls how that content looks.</dd>
</dl>

Nesting lists correctly

Lists can contain other lists, which is how multi-level menus and outlines are built. The rule is that the nested list goes inside an li, as in the "Plan the day" item above. A very common mistake is placing the inner ul directly between two li elements. Browsers usually still display it, but the HTML is invalid, and screen readers may announce the wrong structure. Only li elements (plus script-supporting tags) are allowed as direct children of ul and ol.

Styling lists with CSS

The list-style-type property changes markers (disc, circle, square, decimal, lower-roman, or none). list-style-position: inside moves the marker inside the text block. To build a horizontal navigation bar, set list-style: none, remove the default padding and margin on the ul, and use display: flex to line the items up.

Be aware that removing bullets with list-style: none can cause Safari's VoiceOver to stop announcing the element as a list. If the list semantics matter, adding role="list" to the ul restores them.

Choosing the right list

Ask one question: would reordering the items change the meaning? If yes, use ol. If no, use ul. If each item is a name paired with an explanation, use dl. Avoid faking lists with line breaks and dashes; real list markup gives screen readers an item count and lets CSS style everything consistently.

Takeaway: use ul, ol or dl according to meaning, keep only li as direct children of list elements, nest new lists inside an item, and style markers with CSS rather than extra characters.

Ready to master real-world web development?

Learn HTML, CSS3, Bootstrap and JavaScript hands-on with mentor-led sessions.

Explore Course