HTML Lists
9–12 MINS READ
Agenda
- HTML Lists
- Unordered Lists
- Ordered Lists
- CSS Lists Properties
- start attribute
- Description Lists
HTML Lists
- There are 2 kinds of lists in HTML: unordered or bulleted lists and ordered or numbered lists.
Unordered list tag pairs
- An unordered list contains a list of items that don’t need to be in a particular order.
- The
<ul>
and</ul>
tags are used to create unordered or bulleted lists. - Items in the lists are added by using the
<li>
and</li>
tags.
<!DOCTYPE html>
<html>
<head>
<title>HTML Lists</title>
</head>
<body>
<h1>Most Popular Web Browsers</h1>
<ul>
<li>Mozilla Firefox</li>
<li>Google Chrome</li>
<li>Opera Browser</li>
<li>Microsoft Edge</li>
<li>Safari Browser</li>
</ul>
</body>
</html>
Ordered list tag pairs
- An ordered list is useful for presenting a series of steps that the user should perform in order.
- The
<ol>
and</ol>
tags are used to create ordered lists or numbered lists.
<!DOCTYPE html>
<html>
<head>
<title>HTML Lists</title>
</head>
<body>
<h1>Phases of Web Development Life Cycle</h1>
<ol>
<li>Planning</li>
<li>Analysis</li>
<li>Design</li>
<li>Development</li>
<li>Testing</li>
<li>Implementation</li>
<li>Maintenance</li>
</ol>
</body>
</html>
CSS Lists Properties
- Set different list item markers for ordered lists.
- Set different list item markers for unordered lists.
- Set an image as the list item marker.
- Add background colors to lists and list items.
list-style-type
property
- The list-style-type property is used to define the style of the list item marker.
- The following values below explains how to change the marker for unordered list items.
- The disc value sets the list item marker to a bullet.
- The circle value sets the list item marker to a circle.
- The square value sets the list item marker to a square.
- The none value will not display markers on list items.
disc
value
<body>
<h1>Most Popular Web Browsers</h1>
<ul style="list-style-type: disc;">
<li>Mozilla Firefox</li>
<li>Google Chrome</li>
<li>Opera Browser</li>
<li>Microsoft Edge</li>
<li>Safari Browser</li>
</ul>
</body>
Output
Most Popular Web Browsers
- Mozilla Firefox
- Google Chrome
- Opera Browser
- Microsoft Edge
- Safari Browser
circle
value
<body>
<h1>Most Popular Web Browsers</h1>
<ul style="list-style-type: circle;">
<li>Mozilla Firefox</li>
<li>Google Chrome</li>
<li>Opera Browser</li>
<li>Microsoft Edge</li>
<li>Safari Browser</li>
</ul>
</body>
Output
Most Popular Web Browsers
- Mozilla Firefox
- Google Chrome
- Opera Browser
- Microsoft Edge
- Safari Browser
square
value
<body>
<h1>Most Popular Web Browsers</h1>
<ul style="list-style-type: square;">
<li>Mozilla Firefox</li>
<li>Google Chrome</li>
<li>Opera Browser</li>
<li>Microsoft Edge</li>
<li>Safari Browser</li>
</ul>
</body>
Output
Most Popular Web Browsers
- Mozilla Firefox
- Google Chrome
- Opera Browser
- Microsoft Edge
- Safari Browser
none
value
<body>
<h1>Most Popular Web Browsers</h1>
<ul style="list-style-type: none;">
<li>Mozilla Firefox</li>
<li>Google Chrome</li>
<li>Opera Browser</li>
<li>Microsoft Edge</li>
<li>Safari Browser</li>
</ul>
</body>
Output
Most Popular Web Browsers
- Mozilla Firefox
- Google Chrome
- Opera Browser
- Microsoft Edge
- Safari Browser
list-style-type
property
- The following values sets the marker for ordered list items.
- The lower-alpha value is used to set the marker of a list item in lowercase letters.
- The upper-alpha value is used to set the marker of a list item in uppercase letters.
- The lower-roman value is used to set the marker of a list item in lowercase roman numbers.
- The upper-roman value is used to set the marker of a list item in uppercase roman numbers.
lower-alpha
value
<body>
<h1>Phases of WDLC</h1>
<ol style="list-style-type: lower-alpha;">
<li>Planning</li>
<li>Analysis</li>
<li>Design</li>
<li>Development</li>
<li>Testing</li>
<li>Implementation</li>
<li>Maintenance</li>
</ol>
</body>
Output
Phases of WDLC
- Planning
- Analysis
- Design
- Development
- Testing
- Implementation
- Maintenance
upper-alpha
value
<body>
<h1>Phases of WDLC</h1>
<ol style="list-style-type: upper-alpha;">
<li>Planning</li>
<li>Analysis</li>
<li>Design</li>
<li>Development</li>
<li>Testing</li>
<li>Implementation</li>
<li>Maintenance</li>
</ol>
</body>
Output
Phases of WDLC
- Planning
- Analysis
- Design
- Development
- Testing
- Implementation
- Maintenance
lower-roman
value
<body>
<h1>Phases of WDLC</h1>
<ol style="list-style-type: lower-roman;">
<li>Planning</li>
<li>Analysis</li>
<li>Design</li>
<li>Development</li>
<li>Testing</li>
<li>Implementation</li>
<li>Maintenance</li>
</ol>
</body>
Output
Phases of WDLC
- Planning
- Analysis
- Design
- Development
- Testing
- Implementation
- Maintenance
upper-roman
value
<body>
<h1>Phases of WDLC</h1>
<ol style="list-style-type: upper-roman;">
<li>Planning</li>
<li>Analysis</li>
<li>Design</li>
<li>Development</li>
<li>Testing</li>
<li>Implementation</li>
<li>Maintenance</li>
</ol>
</body>
Output
Phases of WDLC
- Planning
- Analysis
- Design
- Development
- Testing
- Implementation
- Maintenance
list-style-image
property
- The list-style-image property used to specify an image as the list item marker in unordered lists.
<ul style=“list-style-image:url(‘image.jpg’)”>
<li>item 1</li>
<li>item 2</li>
</ul>
<body>
<h1>Most Popular Web Browsers</h1>
<ul style="list-style-image: url(‘checkmarker.png‘);">
<li>Mozilla Firefox</li>
<li>Google Chrome</li>
<li>Opera Browser</li>
<li>Microsoft Edge</li>
<li>Safari Browser</li>
</ul>
</body>
Output
Most Popular Web Browsers
- Mozilla Firefox
- Google Chrome
- Opera Browser
- Microsoft Edge
- Safari Browser
list-style-position
property
- The list-style-position property specifies the position of the list item marker in unordered lists.
- The outside value means that the bullet points will be outside the list item. The start of each line of a list item will be aligned vertically.
- The inside value means that the bullet points will beinside the list item. The list item will be part of the text and push the text at the start.
outside
value
<body>
<h3>To create a web page:</h3>
<ol style="list-styl-position: outside;">
<li>Open a Text Editor (Notepad) or Source Code Editor (Sublime Text) program.</li>
<li>Save the file as .html (File - save as - select HTML)</li>
<li>Write your HTML code.</li>
<li>Double-click on the saved file, and it will be opened in your default browser.</li>
</ol>
</body>
Output
To create a web page:
- Open a Text Editor (Notepad) or Source Code Editor (Sublime Text) program.
- Save the file as .html (File - save as - select HTML).
- Write your HTML code.
- Double-click on the saved file, and it will be opened in your default browser.
inside
value
<body>
<h3>To create a web page:</h3>
<ol style="list-styl-position: inside;">
<li>Open a Text Editor (Notepad) or Source Code Editor (Sublime Text) program.</li>
<li>Save the file as .html (File - save as - select HTML)</li>
<li>Write your HTML code.</li>
<li>Double-click on the saved file, and it will be opened in your default browser.</li>
</ol>
</body>
Output
To create a web page:
- Open a Text Editor (Notepad) or Source Code Editor (Sublime Text) program.
- Save the file as .html (File - save as - select HTML).
- Write your HTML code.
- Double-click on the saved file, and it will be opened in your default browser.
list-style
property
- The list-style property is a shorthand property. It is use to set all the list properties in one declaration.
- When using the shorthand property, the order of the property values are:
- list-style-type
- list-style-position
- list-style-image
start
attribute
- The start attribute of the
<ol></ol>
tag pair defines the start of the counting from specified number.
<body>
<h3>To create a web page:</h3>
<ol start="10">
<li>Open a Text Editor (Notepad) or Source Code Editor (Sublime Text) program.</li>
<li>Save the file as .html (File - save as - select HTML)</li>
<li>Write your HTML code.</li>
<li>Double-click on the saved file, and it will be opened in your default browser.</li>
</ol>
</body>
Output
To create a web page:
- Open a Text Editor (Notepad) or Source Code Editor (Sublime Text) program.
- Save the file as .html (File - save as - select HTML).
- Write your HTML code.
- Double-click on the saved file, and it will be opened in your default browser.
Description List
HTML also supports description lists.
- A description list is a list of terms, with a description of each term.
- The
<dl></dl>
tag pair defines the description list. - The
<dt></dt>
tag pair defines the term (name). - The
<dd></dd>
tag pair describes each term.
<body>
<h2>Description List</h2>
<dl>
<dt>Web Page</dt>
<dd>
is a document commonly written in HTML that is accessible through the internet
or other network using a web browser.
</dd>
<dt>Website</dt>
<dd>
is a collection of related web pages, including multimedia content, typically
identified with a common domain name, and pulished on at least one web server.
</dd>
</dl>
</body>
Output
Description List
- Web Page
- is a document commonly written in HTML that is accessible through the internet or other network using a web browser.
- Website
- is a collection of related web pages, including multimedia content, typically identified with a common domain name, and pulished on at least one web server.
Credits
This webpage was created based on lessons provided by Rose Anne G. Cochanco as part of Web Development subject.