Lists are quite common, so it makes sense to have lists. HTML supports unordered, ordered, and lists of definitions. Unordered lists can be thought of as bullet points, and without CSS we do get bullets shown for each item on the list. Ordered list are numbered lists, meaning that each item in the list is numbered. Definitions are your list of terms that you often see in textbooks and other academic material.
All three types of list work in a very similar manner, with ordered and unordered list being trivially easy to switch between. To create an unordered list, we start with a <ul> tag. Between the start and end of this tag, we use <li> to indicate a list item. Here is a simple example:
<ul>
<li>first entry</li>
<li>second entry</li>
<li>third entry</li>
<li>fourth entry</li>
</ul>
If we were to replace the <ul> tag with <ol> (and obviously the </ul> with </ol>) then we would end up with the following result:
List items can contain whatever you want, including other lists. Placing a list inside another list is known as nesting. The code below is an example of nesting unordered lists.
<ul>
<li>first entry</li>
<li>second entry
<ul>
<li>first sub-entry</li>
<li>second sub-entry</li>
</ul>
</li>
<li>third entry
<ul>
<li>first sub-entry
<ul>
<li>first sub-sub-entry</li>
<li>second sub-sub-entry</li>
</ul>
</li>
<li>second sub-entry</li>
</ul>
</li>
</li>
<li>fourth entry</li>
</ul>
Again, switching ≶ul> to <ol> would then result in the following output:
Mixing between the two types of lists is also possible. Simply have some
The final type of list, which is only vaguely a list, is the definitions list. This works similar to the above lists but each item of the list has two different tags used to describe it instead of just one. To start a definitions list you use the <dl> tag. Each element in this list consists of a term and a description. To specify the term you use the <dt> tag. To specify the description of the term you use the <dd> tag. Here is a simple example:
<dl>
<dt>word to define</dt>
<dd>definition of word</dd>
<dt>second word to define</dt>
<dd>definition of second word</dd>
<dt>third word to define</dt>
<dd>definition of third word</dd>
</dl>
The cheat sheet for this chapter.
A brief history of HTML
What makes up a HTML file
How tags are used to create HTML elements
How to display things such as <, >, &, 😀
Linking to other pages, other sites, and within the page
Adding images and image maps to your page.
Ordered and unordered lists and nesting lists.
Tables with spanning rows and columns.
The game of NIM is the project for this chapter.
How my solution to the NIM game was put together
Solving Nim.