InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

HTML tags

  • audio
  • input checkbox
  • label
  • li
  • ol
  • pre
  • template
  • ul
  • video
 
  • Home
  • > Tutorials
  • > HTML
  • > HTML tag

HTML li tag

on Mar 12, 2016

HTML li tag (<li>) can be used to create a list item. It can be used either in unordered list – ul (<ul>) or in ordered list – ol (<ol>). Also note that there can be nested lists (using ul and/or ol) also.

Attributes

Specific HTML attributes (in addition to global attributes) for li tag are

  • value: The ordinal value of the list item. Permitted only if the li element is a child of an ol element. Note that value attribute was deprecated in HTML4 but is supported in HTML5
  • type (deprecated)
  • start (deprecated)
  • compact (deprecated)

CSS property display

The default value of li element’s display property is list-item.

li {
  display: list-item;
}

Example – li tag with ul and ol

Unordered list
<ul>
<li>item1</li> <li>item2</li> <li>item3</li>
</ul>

Ordered list
<ol>
<li>item1</li> <li>item2</li> <li>item3</li>
</ol>
refresh done
try it online

Example – li tag with attribute value

When a value is assigned in li tag, that becomes the ordinal value of that item. Next item ordinal value is obtained by taking taken value if not specified.

Ordered list
<ol>
  <li value="2">itemA</li>
  <li value="4">itemB</li>
  <li>itemC</li>
  <li>itemD</li>
</ol>
refresh done
try it online

Example – li tag with display inline

<style>
  li {display: inline; }
</style>

Unordered list
<ul>
<li>item1</li> <li>item2</li> <li>item3</li>
</ul>

Ordered list
<ol>
<li>item1</li> <li>item2</li> <li>item3</li>
</ol>
refresh done
try it online

Related

  • CSS list-style - shorthand for list marker type, image and position
  • CSS list-style-type - specify marker (disc, square, numeric, etc.) for a list
  • CSS list-style-position - specify if list markers will be outside or inside
  • CSS list-style-image - use image as marker in list
  • HTML ol tag
  • HTML ul tag

Specification

  • W3C HTML5 li (list item) specification

Suggested posts:

  1. PHP – print array in one line
  2. WordPress mysql query to get all posts with a specific custom field
  3. Running php eval on code with tags
  4. Mysql multi column Index
  5. Python value in array (list) check
  6. React Overview
  7. CSS text-overflow – truncate text with three dots
  8. Make an element draggable using Vanilla Javascript
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged HTML tag, Tutorials
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress