HTML 3
Creating Lists in HTML
Hello friends,
Now it’s time to create lists and tables... Let's start with lists first. In HTML, there are three types of lists: ordered lists, unordered lists, and definition lists. We will examine each type separately.
Ordered List
<html>
<body>
<ol>
<li>Tea</li>
<li>Coffee</li>
<li>Milk</li>
<li>Water</li>
</ol>
</body>
</html>
Unordered List
<html>
<body>
<ul>
<li>Tea</li>
<li>Coffee</li>
<li>Milk</li>
<li>Water</li>
</ul>
</body>
</html>
In an ordered list, we use the <ol>
tag, and each item is placed within <li>...</li>
tags. The browser displays it as follows:
-
Tea
-
Coffee
-
Milk
-
Water
The only difference in an unordered list is that we use <ul>
instead of <ol>
. The result in the browser appears as:
-
Tea
-
Coffee
-
Milk
-
Water
In an ordered list, we can customize numbering with numbers, letters, or Roman numerals. Let's see examples:
<html>
<body>
<h3>Numbered List</h3>
<ol>
<li>Tea</li>
<li>Coffee</li>
<li>Milk</li>
<li>Water</li>
</ol>
<h3>Uppercase Letter List</h3>
<ol type="A">
<li>Tea</li>
<li>Coffee</li>
<li>Milk</li>
<li>Water</li>
</ol>
<h3>Lowercase Letter List</h3>
<ol type="a">
<li>Tea</li>
<li>Coffee</li>
<li>Milk</li>
<li>Water</li>
</ol>
<h3>Roman Numeral List</h3>
<ol type="I">
<li>Tea</li>
<li>Coffee</li>
<li>Milk</li>
<li>Water</li>
</ol>
<h3>Lowercase Roman Numeral List</h3>
<ol type="i">
<li>Tea</li>
<li>Coffee</li>
<li>Milk</li>
<li>Water</li>
</ol>
</body>
</html>
These are the available options for ordered lists. Now, let’s move on to unordered lists.
<html>
<body>
<h3>Disc List</h3>
<ul type="disc">
<li>Tea</li>
<li>Coffee</li>
<li>Milk</li>
<li>Water</li>
</ul>
<h3>Circle List</h3>
<ul type="circle">
<li>Tea</li>
<li>Coffee</li>
<li>Milk</li>
<li>Water</li>
</ul>
<h3>Square List</h3>
<ul type="square">
<li>Tea</li>
<li>Coffee</li>
<li>Milk</li>
<li>Water</li>
</ul>
</body>
</html>
Definition Lists
Definition lists use different tags: <dl>
, <dt>
, and <dd>
. Let's start with an example and then explain it.
<html>
<body>
<dl>
<dt>Hot Beverages</dt>
<dd>Tea</dd>
<dd>Coffee</dd>
<dt>Cold Beverages</dt>
<dd>Water</dd>
<dd>Milk</dd>
</dl>
</body>
</html>
Output:
Hot Beverages
-
Tea
-
Coffee
Cold Beverages
-
Water
-
Milk
The <dl>
tag defines the list. <dt>
is used for the category title, while <dd>
is used for the list items.
Nested List Example
Let’s practice with a nested list:
<html>
<body>
<h3>Top 3 Football Teams by Country</h3>
<ul>
<li>Turkey</li>
<ol type="a">
<li>Beşiktaş</li>
<li>Galatasaray</li>
<li>Fenerbahçe</li>
</ol>
<li>England</li>
<ol type="a">
<li>Chelsea</li>
<li>Liverpool</li>
<li>Man. United</li>
</ol>
<li>Spain</li>
<ol type="a">
<li>Real Madrid</li>
<li>Barcelona</li>
<li>Atletico Madrid</li>
</ol>
</ul>
</body>
</html>
Yes, you guessed it right—I am a Beşiktaş fan, and I prefer Ronaldo over Messi! :))
In the next lesson, we will cover table creation. See you then!
Yorumlar
Yorum Gönder