Attributes for Lists
In HTML, you can use various attributes to customize the appearance and behavior of lists. Here are some commonly used attributes for lists along with their syntax:
1. Type Attribute (for Ordered Lists):
Specifies the type of marker to use in an ordered list. The values can be “1” (default, numbers), “A” (uppercase letters), “a” (lowercase letters), “I” (uppercase Roman numerals), or “i” (lowercase Roman numerals).
Syntax:
<ol type="A">
<li>Item 1</li>
<li>Item 2</li>
</ol>
2. Start Attribute (for Ordered Lists):
Specifies the starting value of the first list item in an ordered list.
Syntax:
<ol start="10">
<li>Item 10</li>
<li>Item 11</li>
</ol>
3. Value Attribute (for List Items):
Specifies the value of an individual list item in an ordered list. This attribute can be used to override the default numbering.
Syntax:
<ol>
<li value="100">Item 100</li>
<li>Item 101</li>
</ol>
4. Compact Attribute (for Lists):
Indicates that the list should render with reduced spacing between list items. This attribute is deprecated in HTML5 and is not recommended for use.
Syntax:
<ul compact>
<li>Item 1</li>
<li>Item 2</li>
</ul>
5. Type Attribute (for Unordered Lists):
Specifies the type of bullet or marker to use in an unordered list. The values can be “disc” (default filled circle), “circle” (hollow circle), or “square” (filled square).
Syntax:
<ul type="circle"> <!--circle, disk, square-->
<li>Item 1</li>
<li>Item 2</li>
</ul>
Note–
Please note that the ‘type
‘ attribute for unordered lists (<ul>
) is not supported in HTML5, and it’s recommended to use CSS for styling list markers instead. Also, the compact
attribute for lists is deprecated and should not be used in modern HTML documents. It’s better to use CSS for controlling the spacing and appearance of lists.