ul tag (XHTML 1.1)
unordered listThe ul tag is used for creating an Unordered List, which is a list with bulletpoints instead of e.g. numbers or letters indicating an order. You can create a simple unordered list like this:
<ul> <li>John Doe</li> <li>Jane Doe</li> <li>...and all the others</li> </ul>
The result will look something like this:
- John Doe
- Jane Doe
- ...and all the others
As you can see, we use the <li> tag. It simply tells the browser that the containing text is a list item. Everything within a set of <ul> tags should be list items.
The type attribute
The most interesting attribute of the ul tag, is the type attribute. It allows you to define how the bullet points will look like. Click the type link, for a list of possible values. Here's an example where we use square bulletpoints instead of the default round ones:
<ul type="square"> <li>John Doe</li> <li>Jane Doe</li> <li>...and all the others</li> </ul>
The result looks like this:
- John Doe
- Jane Doe
- ...and all the others
Unfortunately, the type attribute has been deprecated. If you wish to create pages which validates, you should use the CSS alternative list-style-type instead:
<ul style="list-style-type: square;"> <li>John Doe</li> <li>Jane Doe</li> <li>...and all the others</li> </ul>
In general, CSS offers you a lot of options for styling you list. You can play around with the following CSS properties:
Attributes
| Attribute | Deprecated | Required | Description |
|---|---|---|---|
| class | space-separated list of classes | ||
| compact | X | reduced interitem spacing | |
| dir | direction for weak/neutral text | ||
| id | document-wide unique id | ||
| lang | language code | ||
| style | associated style info | ||
| title | advisory title | ||
| type | X | bullet style |
Events
| Event | Description |
|---|---|
| onclick | a pointer button was clicked |
| ondblclick | a pointer button was double clicked |
| onkeydown | a key was pressed down |
| onkeypress | a key was pressed and released |
| onkeyup | a key was released |
| onmousedown | a pointer button was pressed down |
| onmousemove | a pointer was moved within |
| onmouseout | a pointer was moved away |
| onmouseover | a pointer was moved onto |
| onmouseup | a pointer button was released |