Introduction
The <ul>
(Unordered List) element in HTML is used to create a list of items where the order or sequence of items is not important. Each item in the list is represented by the <li>
(List Item) element.
Here’s an example of how to use the <ul>
element:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<ul>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ul>
</body>
</html>
Output :
In this example, the default rendering is usually as a bulleted list.
You can also use the <ul>
element with different list styles by changing the list-style-type
CSS property.
For example, you can use list-style-type: square;
to have square bullets.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
ul {
list-style-type: square;
}
</style>
</head>
<body>
<ul>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ul>
</body>
</html>
Output :
The <ul>
element is often used in scenarios where the order of items is not significant, such as a list of features, characteristics, or items in a navigation menu. It is a versatile element for creating visually structured and organized content on web pages.