搜尋
首頁web前端html教學HTML 無序列表

HTML 無序列表

Sep 04, 2024 pm 04:43 PM
htmlhtml5HTML TutorialHTML PropertiesHTML tags

Lists in HTML are a concept of gathering a number of data or elements arranged in a specific order organized for the purpose of being used in the program execution. HTML uses three types of lists, namely Ordered List, Unordered List and Definition List, where Unordered List is a type of list where the data or elements can be arranged in the list in no specific order. The syntax for the HTML Unordered List is

  • ………..
, where
    is the tag that indicates the unordered list type.

    The three types of lists we could use to bring order to the web pages. Below are the different types:

  1. Ordered List
  2. Unordered list
  3. Definition List

In this article, we shall go through the unordered list specification with an example. The unordered list is a list that doesn’t require any order of numbering in their list; instead, we use bullets for the list levels.

Syntax of HTML Unordered List

The syntax for the unordered list is similar to the ordered list we created in the previous article. Unordered list is created using an element named

    element and ends with
tag. The list item is embedded inside the
    element.

  • ………..

Example #1

This shows how this short item list is implemented in a browser.


<title> Demo on Unordered list</title><br>   

<h1 id="u-Demo-on-Unordered-list-u"><u>Demo on Unordered list</u></h1>
<h2 id="Ingredients-for-making-of-cake">Ingredients for making of cake</h2>
<h3>
<ul type="square">
<li>Baking Powder</li>
<li>Flour</li>
<li> Sugar</li>
<li>Coco poder</li>
</ul>
<h3>

</h3>
</h3>

Output:

This will give you the result like

HTML 無序列表

Example #2

Unordered List with colors and for the positions.



<title>unordered list Demo2</title>


<h1 id="Unordered-Disc">Unordered Disc</h1>
  • Lion
  • Tiger
  • Giraffe
  • Camel

Top Rhymes

  • Johny Johny Yes papa
  • Wheels on the Bus
  • Baa Baa Black Sheep

Fruits Name List

  • Avacado
  • Orange
  • Pears
  • Banana

Output:

HTML 無序列表

Types of Attributes for HTML Unordered List

To figure the unordered list, there are three primary types of attributes for this unordered element. The unordered list is used where it is not required to represent the lists in any specific orders. The following sections explain the related attributes and examples of them.

This attribute gives the type of bullets to be used in the list.

  • type =’disc’ – Gives default bullet structure
  • type =’square’ – Looks like solid box bullets
  • type =’circle’ – Gives Hollow box structure

1. Attribute type=’disc.’

This is the default type, and all the items are marked as bullets. Here we use type attribute, and all these attributes support in HTML 3, To define under HTML5, we are supposed to implement list-style CSS. Here is an example demo.

Example:


<title> Demo on Unordered list Types</title><br>   

<h1 id="u-Demo-on-Unordered-list-Types-u"><u>Demo on Unordered list Types</u></h1>
  • This is Program Agenda.
    • First a Welcome Note
    • Second We Start with the talks
  • Opening Speech
  • Mrs.Claria Winston from Ireland and Eyjolfur From Bank of America.
  • Tea Break
  • Last part from the topic Data Lake By Surendran Thomas.

Output:

HTML 無序列表

2. Attribute type=’square.’

Here the items are marked with Square bullets.

Example:

Demonstrating the HTML code with the square bullet embedded with style color and the position.



<meta name="viewport" content="width=device-width, initial-scale=1.5">
<style>
ul {
list-style: square;
}
ul li::before {
content: "\1022";
color: pink;
font-weight: bold;
display: inline-block;
width: 0.8em;
margin-left: -1em;
}
</style>


<h2 id="List-of-top-hollywood-movies-Square">List of top hollywood movies-Square</h2>
  • World Of the wars
  • Mission Impossible
  • Independence Day special
  • Behind enemy lines

Output:

HTML 無序列表

3. Attribute type=’circle.’

This attribute gives hollow bullet values. Below are the example rendering circle and square attribute together with the nested lists.

Example:


<title> EDUCBA List Example </title>
;style>
h3{
color:orange;
}
ul{
list-style: none;
}
ul li::before {
content: "\25AA";
color: brown;
display: inline-block;
width: 1em;
margin-left: -0.8em;
font-weight: bold;
font-size:1rem;
}



<h1 id="List-of-Mobiles"> List of Mobiles</h1>
  • Redmi Xiami
  • Iphone
  • Samsung
  • Nokia

Mobile Operating System Supports

  • Android
  • Windows phone
  • Samsung
  • Nokia

Output:

HTML 無序列表

Replacing HTML list Items with Customizable Images

This would ultimately enhance the overall theme and makes the website visually good. The default bullets are replaced by native style or even can customizable using images with CSS help. Actually speaking, there are three styling lists to be used in HTML. Here we go with a list-style-type and list-style-image.

Using image bullet is to make the lists more unique and differentiate the information by type, Giving the presentation a look on the web page.

In the below example, the examples are demonstrated by style properties between the list elements.

Example #1 – Style properties between the list elements



<title>HTML unordered list with Styles</title>


<style>
ul li {
background: red;
}
ul.in.li {
list-style: circle inside none;
color: red;
left: -20px;
position: inside;
text-align: left;
width: 27px;
}</style>
  • Finland is a Scandinavian Country
  • Oslo is the capital city
  • Iceland is known for its beauty , hiking, fishing
  • Ranked among the chillness country in europe

Output:

This will give out the output like

HTML 無序列表

Example #2 – With image style



<style>
ul {
list-style-image: url('sqpurple.gif');
}
</style>


<h2 id="The-list-style-Demo">The list-style- Demo</h2>
<p>Harry Potter Characters:</p>
  • Harry
  • Hermione
  • Ron Weasely

Output:

HTML 無序列表

結論

現在我們了解如何在 HTML 中建立無序列表。我們已經透過不同的範例了解了無序塊元素如何在建立網頁中發揮作用,並探索了一些清單功能。即使這也可以用在導覽選單中垂直顯示。無序列表的建立非常簡單;考慮在哪裡修復此方法以獲得最佳位元非常重要。換句話說,完美的文件更喜歡使用 HTML 清單格式。

以上是HTML 無序列表的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
HTML行動:網站結構的示例HTML行動:網站結構的示例May 05, 2025 am 12:03 AM

HTML用於構建結構清晰的網站。 1)使用標籤如、、定義網站結構。 2)示例展示了博客和電商網站的結構。 3)避免常見錯誤如標籤嵌套不正確。 4)優化性能通過減少HTTP請求和使用語義化標籤。

您如何將圖像插入HTML頁面?您如何將圖像插入HTML頁面?May 04, 2025 am 12:02 AM

toinsertanimageIntoanhtmlpage,usethetagwithsrcandaltattributes.1)usealttextforAcccessibilityandseo.2)instementRcsetForresponSiveImages.3)applylazyloadingWithLoadingWithLoading =“ lazy” tooptimizeperformance.4)tooptimizeperformance.4)

HTML的目的:啟用Web瀏覽器可以顯示內容HTML的目的:啟用Web瀏覽器可以顯示內容May 03, 2025 am 12:03 AM

HTML的核心目的在於讓瀏覽器理解並展示網頁內容。 1.HTML通過標籤定義網頁結構和內容,如、到、等。 2.HTML5增強了多媒體支持,引入了和標籤。 3.HTML提供了表單元素,支持用戶交互。 4.優化HTML代碼可提升網頁性能,如減少HTTP請求和壓縮HTML。

為什麼HTML標籤對Web開發很重要?為什麼HTML標籤對Web開發很重要?May 02, 2025 am 12:03 AM

htmltagsareessentialforwebdevelopmentastheyandendenhancewebpages.1)semantictagsimproveaccessibilityandseo.2)semanteLayOut,語義和互動性。 3)poseriblesibilityandseoandseo.3)poseriblesoftagscanoftagscanoftagscanoptagscanoptimizeperefeneandimizeanDenSuroceRecRoscRoss-BrowserCrowserCercerComercompatibility。

說明將一致的編碼樣式用於HTML標籤和屬性的重要性。說明將一致的編碼樣式用於HTML標籤和屬性的重要性。May 01, 2025 am 12:01 AM

一致的HTML編碼風格很重要,因為它提高了代碼的可讀性、可維護性和效率。 1)使用小寫標籤和屬性,2)保持一致的縮進,3)選擇並堅持使用單引號或雙引號,4)避免在項目中混合使用不同風格,5)利用自動化工具如Prettier或ESLint來確保風格的一致性。

如何在 Bootstrap 4 中實現多項目輪播?如何在 Bootstrap 4 中實現多項目輪播?Apr 30, 2025 pm 03:24 PM

在Bootstrap4中實現多項目輪播的解決方案在Bootstrap4中實現多項目輪播並不是一件簡單的事情。雖然Bootstrap...

deepseek官網是如何實現鼠標滾動事件穿透效果的?deepseek官網是如何實現鼠標滾動事件穿透效果的?Apr 30, 2025 pm 03:21 PM

如何實現鼠標滾動事件穿透效果?在我們瀏覽網頁時,經常會遇到一些特別的交互設計。比如在deepseek官網上,�...

HTML 視頻的播放控件樣式怎麼修改HTML 視頻的播放控件樣式怎麼修改Apr 30, 2025 pm 03:18 PM

無法直接通過CSS修改HTML視頻的默認播放控件樣式。 1.使用JavaScript創建自定義控件。 2.通過CSS美化這些控件。 3.考慮兼容性、用戶體驗和性能,使用庫如Video.js或Plyr可簡化過程。

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

Atom編輯器mac版下載

Atom編輯器mac版下載

最受歡迎的的開源編輯器

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )專業的PHP整合開發工具

MantisBT

MantisBT

Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

mPDF

mPDF

mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),