Table of Contents
INTRODUCTION
List is a collection of items which are related. Lists create a well structured and easy-to-read information. In HTML there are 3 types of list available.
Unordered List Element - ul
The HTML Unordered list is a list where list items are not in any sequence or order. It is shown by default as bulleted list(•) by browser. Unordered list is used when the list items do not follow any sequence or order.
The HTML <ul> element is used to create unordered list. The <li> element is used for list items. The <ul> element can contain Zero or more <li>, <script> and <template> elements.
Syntax :
<ul>
<li> item1-content </li>
<li> item2-content </li>
<li> item3-content </li>
<li> item4-content </li>
</ul>
Example :
<ul>
<li> Chapter-1 </li>
<li> Chapter-2 </li>
<li> Chapter-3 </li>
<li> Chapter-4 </li>
</ul>
Output :
- Chapter-1
- Chapter-2
- Chapter-3
- Chapter-4
Tag Omission
The HTML <ul> element must have both start tag and end tag.
ATTRIBUTES
- The <ul> element only has global attributes.
- The compact and type attributes has been deprecated.
Important Properties
- Unordered list items are shown with bullet points by default. It is not limited to bullet and take several forms like as dots, circles, squares and others by using the CSS list-style-type property.
- To remove the marker use the CSS property list-style-type with value set to none.
- You can use an custom image as marker by using CSS list-style-image property.
- The <ul> and <ol> elements can be nested to any depth. Additionally, nesting lists can be freely alternated between <ol> and <ul> without limitations.
Frequently Asked Questions(FAQ)
How to change the bullet style of an unordered list?
What's the difference between an unordered list (<ul>) and an ordered list (<ol>)?
Ordered List (<ol>) displays items with numbers (1, 2, 3) or letters (A, B, C) by default. It is used when the order of items does matter (e.g., step-by-step instructions)