
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML li Value Attribute
The value attribute of the <li> element is used to set the value of the list item. Since the value is a number, it would be set only for the ol element in HTML i.e. the ordered list.
Following is the syntax −
<li value="num">
Above, num is the value of the list item in an ordered list.
Let us now see an example to implement the value attribute of the <li> element −
Example
<!DOCTYPE html> <html> <body> <h1>Subjects</h1> <p>Following are the subjects −</p> <ol> <li>Maths</li> <li>Science</li> <li>English</li> <li>French</li> </ol> <p>Remaining subjects −</p> <ol> <li value="5">Coffee</li> <li>Accounts</li> <li>Programming</li> <li>Networking</li> </ol> </body> </html>
Output
In the above example, we have set two unordered lists −
<p>Following are the subjects −</p> <ol> <li>Maths</li> <li>Science</li> <li>English</li> <li>French</li> </ol> <p>Remaining subjects −</p> <ol> <li value="5">Coffee</li> <li>Accounts</li> <li>Programming</li> <li>Networking</li> </ol>
One of them is not beginning from the default 1. We have set a different value using the value attribute −
<ol> <li value="5">Coffee</li> <li>Accounts</li> <li>Programming</li> <li>Networking</li> </ol>
Advertisements