- HTML Tutorial
- HTML - Home
- HTML - History and Evolution
- HTML - Overview
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Headings
- HTML - Paragraphs
- HTML - Quotations
- HTML - Comments
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Style Sheet
- HTML - CSS Classes
- HTML - CSS IDs
- HTML - Images
- HTML - Image Map
- HTML Tables
- HTML - Tables
- HTML - Headers & Caption
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Iframes
- HTML - Blocks
- HTML Backgrounds
- HTML - Backgrounds
- HTML Colors
- HTML - Colors
- HTML - RGB
- HTML - HEX
- HTML - HSL
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Code Builder
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - <li>Tag
In an HTML, the <li> tag is used to represent an item in a list. It should be rooted in the parent elements, which are: an unordered list <ul>, an ordered list <ol>, or menus <menu>. Items in unordered lists <ul> and in menus <menu> are displayed in bullet points, whereas in ordered lists, they are displayed in left-ascending counters that are letters, numbers, and Roman numerals.
It includes the global attributes as follows −
- <value> − It is an integer attribute indicating the current ordinal value of the list defined by the <ol> tag. The only allowed values for this element are numbers.
- <type> − It is a character attribute that indicates the numbering type.
Following are the various numbering types of the type attribute −
- type ='a' − for lowercase letters.
- type ='A' − for uppercase letters.
- type ='i' − for lowercase roaman numerals.
- type ='I' − for uppercase roman numerals.
- type ='1' − for numbers.
Syntax
Following is the syntax of the <li> tag −
<parentelement> <li></li> <li></li> …. <parentelement>
Example
In the following program, we are using <ol> tag to create an ordered list. Then, we create a <li> tag within the <ol> tag to display the list items in number format.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML Description lists</title> </head> <body> <ol> <li>HTML</li> <li>CSS</li> <li>JavaScript</li> </ol> </body> </html>
When we run the above code, it will generate an output consisting of the list items displayed on the webpage.
Example
Following is another example of <li> tag. Here, we are creating an ordered list using <ol> tag, and giving the type attribute value as type = 'I'. Then, we create multiple <li> tags within a <ol> tag to display a list of items in Roman numeral format.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML Description lists</title> </head> <body> <ol type='I'> <li>Red</li> <li>Black</li> <li>White</li> <li>Pink</li> </ol> </body> </html>
On running the above code, the output window will pop up, consisting of list items in the roman numerical format on the webpage.
Example
In this example, we are creating an ordered list using the <ol> tag. Then, we create multiple <li> tags within the <ol> tag. We use the value attribute with the value="3" within the <li> tag to give the custom value to the ordered list.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML Description lists</title> </head> <body> <ol type='i'> <li value="3">Red</li> <li>Java</li> <li>Python</li> <li>C++</li> <li>APex</li> </ol> </body> </html>
When we run the above code, it will generate an output displaying the list items starting with a value 3 in roman numeral format on the webpage.
Example
In this program, we are creating an unordered list using the <ul> tag and create multiple <li> tags within the <ul> tag to display the list items in bullet points.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML Description lists</title> </head> <body> <ul> <li>Red</li> <li>Apple</li> <li>Mango</li> <li>Orange</li> <li>Grapes</li> </ul> </body> </html>
On running the above code, it will generate an output displaying the list items on the webpage.