▲Wirig Diagram Hot
▲ ▲ ▼

Understanding UL and LI in HTML

By

When you're delving into HTML (HyperText Markup Language), you might come across tags like <ul> and <li>, especially when aiming to create lists. Understanding what these tags represent and their functionality is crucial for structuring your web content effectively. Let's explore these tags in detail.

Before we dive deep into <ul> and <li>, let's recap the basic concept of lists in HTML. Lists are used to group related items together. HTML offers several types of lists, but we'll focus on unordered and ordered lists, which are represented by the <ul> and <ol> tags respectively.

Unordered Lists

An unordered list is a collection of items without a specific order, often displayed with bullet points. The <ul> tag defines an unordered list, and the <li> tag defines an item in the list.

a screenshot of a computer screen with some type of text in the bottom right corner
a screenshot of a computer screen with some type of text in the bottom right corner
HTML Lists: <ul> vs <ol> – When to Use Which? 📝
HTML Lists: <ul> vs <ol> – When to Use Which? 📝
Learn HTML UL TAg
Learn HTML UL TAg

Here's a basic example of an unordered list:

  • Apples
  • Bananas
  • Cherries

Using the <ul> and <li> Tags

To create an unordered list, wrap your <li> elements inside the <ul> tag. Each <li> tag represents a different item in the list. In the provided example, 'Apples', 'Bananas', and 'Cherries' are each enclosed within separate <li> tags, making them individual list items.

HTML Input Types You Must Remember 📌
HTML Input Types You Must Remember 📌
Lesson 7: HTML Lists (Ordered & Unordered Lists) 📚
Lesson 7: HTML Lists (Ordered & Unordered Lists) 📚
What Is HTML? 💻 HTML for Beginners | Lesson 01
What Is HTML? 💻 HTML for Beginners | Lesson 01

By default, unordered lists are displayed with disc bullets (filled black circles). However, you can change this list-style-type using CSS for a more customized appearance.

Nesting Unordered Lists

You can also nest unordered lists to create sublists. To do this, simply place a <ul> tag within another <ul> tag. This can be useful when you want to group related items together in a hierarchical manner.

Here's an example of nested unordered lists:

URL Structure Explained 🌐 | Learn Parts of a Website Link Easily
URL Structure Explained 🌐 | Learn Parts of a Website Link Easily
an image of a web page with the words in different languages
an image of a web page with the words in different languages
different types of languages used in web development and application development, as well as programming
different types of languages used in web development and application development, as well as programming
URL vs URI vs URN
URL vs URI vs URN
🔗 HTML Links | Learn Hyperlinks in HTML (Lesson 5)
🔗 HTML Links | Learn Hyperlinks in HTML (Lesson 5)
Saidul (@saidul_dev) on X
Saidul (@saidul_dev) on X
  • Fruits
    • Berries
    • Citrus
  • Vegetables
    • Leafy Greens
    • Root Vegetables

Ordered Lists

Ordered lists are similar to unordered lists but display list items with a specific order, using numbers or letters. These lists are defined using the <ol> tag, and each list item is defined with the <li> tag.

Here's an example of an ordered list:

  1. First
  2. Second
  3. Third

In conclusion, mastering the <ul> and <li> tags is essential for creating well-organized, structured content on your web pages. Whether you're listing your favorite fruits, outlining a set of instructions, or organizing a timeline of events, these tags will help you achieve clean, easily navigable, and accessible content for your users.

url vs uri vs urn
url vs uri vs urn
HTML Explained for Beginners | What Is HTML & How It Works (Simple Concept 2026)
HTML Explained for Beginners | What Is HTML & How It Works (Simple Concept 2026)
html
html
💬 Comments ↗ Share ★ Save
AD