首页 > 其他分享 >HTML 18 - Lists

HTML 18 - Lists

时间:2024-05-18 17:09:08浏览次数:27  
标签:18 list Lists Item HTML List Example CSS

 

HTML List is a collection of related infomation. The lists can be ordered or underdered depending on the requirement. In html we can create both order and unorder lists by using <ol> and <ul> tags. Each type of list can be decorated using porper attributes or CSS also. There is one more list which is description list - HTML <dl>, <dt> & <dd> tag are used to create description lists.

Lists in HTML

As HTML offers three ways for specifying lists of information namely ordered, unordered, and definition lists. All lists must contain one or more list items.

Examples of HTML Lists

In the below examples we will see unorder list, order list, description lists, and their variation as well, will use CSS to decorate the list.

HTML Unorder Lists

Unorder lists are marked with bullet points, by using html <ul> & <li> tag we can create a unorder list. This is also know as unorder list.

Example

In this example we will create 5 items in a unorder list.

<!DOCTYPE html>
<html>
<head>
   <title>HTML List</title>
</head>
<body>
   <h2>Example of HTML List</h2>
   <ul>
      <li>HTML</li>
      <li>CSS</li>
      <li>JavaScript</li>
      <li>Java</li>
      <li>JavaFX</li>
   </ul>
</body>
</html>

 

HTML Order Lists

Order list are marked with numbers by default, we can xhnage the number into alphabet, roman numbers, etc. By using html <ol> & <li> tag we can create a order list and using type attribute we can change the default numeric marking.

Example

In this example we will create 5 items in a order list, try to use the type attribute to chnage numeric order marking.

<!DOCTYPE html>
<html>
<head>
   <title>HTML List</title>
</head>
<body>
   <h2>Example of HTML List</h2>
   <ol>
      <li>HTML</li>
      <li>CSS</li>
      <li>JavaScript</li>
      <li>Java</li>
      <li>JavaFX</li>
   </ol>
</body>
</html>

 

HTML Description Lists

Description list is list of items with description, to create a desccription list we can use <dl>, <dt> & <dd> tag.

Example

In this example we will create 3 description list with the descripion.

<!DOCTYPE html>
<html>
<head>
    <title>HTML List</title>
</head>
<body>
    <h2>Example of HTML List</h2>
    <dl>
        <dt>HTML</dt>
        <dd>HyperText markup languague</dd>
        <dt>CSS</dt>
        <dd>Cascading Style Sheet</dd>
        <dt>JS</dt>
        <dd>JavaScript</dd>
    </dl>
</body>
</html>

 

HTML Nested Lists

A list created within another list is known as Nested List. HTML also allow nesting of lists within one another to generate a complex document structures.

Example

In the following example, we are nesting an unordered list within an ordered list.

<!DOCTYPE html>
<html>
<head>
   <title>HTML List</title>
</head>
<body>
   <h2>Example of HTML Nested List</h2>
   <ol>
      <li>Item One</li>
      <li>Item Two
         <ul>
            <li>Subitem A</li>
            <li>Subitem B</li>
         </ul>
      </li>
      <li>Item Three</li>
   </ol>
</body>
</html>

 

Grouping with the <div> Tag

To enhance styling and layout, lists are often wrapped inside the <div> elements. This grouping aids in applying consistent styles and creating visually appealing list structures.

Example

In this example, we are grouping unordered lists with div tag.

<!DOCTYPE html>
<html>
<head>
   <title>HTML List</title>
</head>
<body>
   <h2>Grouping of HTML List elements with div tag</h2>
   <div>
      <p>First List</p>
      <ol>
         <li>Item One</li>
         <li>Item Two</li>
      </ol>
   </div>
   <div>
      <p>Second List</p>
      <ol>
         <li>Item Three</li>
         <li>Item Four</li>
      </ol>
   </div>
</body>
</html>

 

Applying CSS to HTML List

Lists can be styled using CSS to enhance visual presentation. Custom styles can be applied to list items, creating unique and visually appealing designs. For this, we use the <style> tag which is a way of specifying internal CSS.

Example

The following example demonstrate how to apply CSS to the HTML list using style tag.

<!DOCTYPE html>
<html>
<head>
   <title>HTML List</title>
   <style>
      li {
         font-size: 16px;
      }
      div {
         color: red;
      }
   </style>
</head>
<body>
   <h2>HTML List with CSS</h2>
   <div>
      <p>First List</p>
      <ol>
         <li>Item One</li>
         <li>Item Two</li>
      </ol>
   </div>
   <div>
      <p>Second List</p>
      <ol>
         <li>Item Three</li>
         <li>Item Four</li>
      </ol>
   </div>
</body>
</html>

 

Marker Types in HTML Lists

CSS allows customization of marker types for list items. To do so, we use the CSS list-style-type property which can be set to change markers to circles, squares, or other symbols.

Example

In this example, we are using the list-style-type property of CSS to set the markers of list items.

<!DOCTYPE html>
<html>
<head>
   <title>HTML List</title>
   <style>
      li {
         font-size: 16px;
         list-style-type: square;
      }
   </style>
</head>
<body>
   <h2>HTML list-style-type Property</h2>
   <div>
      <p>First List</p>
      <ol>
         <li>Item One</li>
         <li>Item Two</li>
      </ol>
   </div>
   <div>
      <p>Second List</p>
      <ol>
         <li>Item Three</li>
         <li>Item Four</li>
      </ol>
   </div>
</body>
</html>

 

标签:18,list,Lists,Item,HTML,List,Example,CSS
From: https://www.cnblogs.com/emanlee/p/18190434

相关文章

  • Weblogic T3反序列化漏洞(CVE-2018-2628)
    目录前言T3协议概述漏洞复现修复方案前言WebLogicServer是一个企业级的应用服务器,由Oracle公司开发,支持完整的JavaEE规范,包括EJB、JSP、Servlet、JMS等,适合大型分布式应用和高负载场景。T3协议概述T3协议(Two-TierTCP/IPProtocol),是WebLogic中的一种专有协议,建立在TCP/IP协......
  • 用flask框架在html中运行python程序
    目录-app.py-templates-index.html首先安装Flask和OpenCV库pipinstallflaskopencv-python接着创建一个Python脚本,叫做app.pyfromflaskimportFlask,render_template,Responseimportcv2app=Flask(__name__)@app.route('/')defindex():retur......
  • HTML 17 - Tables
     HTMLTablesallowustoputdatainaorganizedwaybyprovidingrowandcolumnfacility.Alsoofferavisualstructurethataidsinclarityandcomprehension,makingthemafundamentalelementinwebdevelopment.WhyTablesareUsedinHTML?Tablesare......
  • HTML 15 - CSS IDs
     HTML"id"isanattributeusedtouniquelyidentifyanelementwithinawebpage.ItservesasalabelforthatelementandenablesJavaScriptandCSStotargetitspecifically.Thisidentificationhelpsinapplyingcustomstyles,makinginter......
  • HTML 16 - Images
    HTMLImagesprovidesavisualcontentforwebpages,enhancinguserexperiencesandconveyinginformation.Theycanbephotographs,graphics,icons,orillustrations.ToinsertanimageonHTMLdocumentwecanuse<img>tag.ReasontouseImagesHTM......
  • HTML 14 - CSS Classes
    InHTML,aclassisanattributethatcanbeappliedtooneormoreelementsandisusedtostyleandcategorizeelementsbasedoncommoncharacteristicsorpurpose.Classesallowsmultipleelementstosharethesamestylingrules.Byassigningthesamec......
  • HTML 13 - Style Sheet
     CSS,orCascadingStyleSheets,isatoolthatdefineshowwebdocumentslookonscreensorinprint.Sinceitsintroductionin1994,theW3Chasencouragedtheuseofstylesheetsforwebdesign.CSSletsyoucontrolthepresentationofyourcontent,w......
  • HTML 12 - Meta Tags
     HTMLletsyouspecifymetadata,whichisadditionalimportantinformationaboutadocument,inavarietyofways.TheMETAelementscanbeusedtoincludename/valuepairsdescribingpropertiesoftheHTMLdocument,suchasauthor,expirydate,alisto......
  • HTML 11 - Phrase Tags
     Thephrasetagshavebeendesignedforspecificpurposes,thoughtheyaredisplayedinasimilarwayasotherbasictagslike<b>,<i>,<pre>,and<tt>,asyouhaveseeninthepreviouschapter.Thischapterwilltakeyouthrough......
  • 20240518模拟赛
    C240518A.传送门(portal)构造一个图使得点\(1\)到\(2\)的最短路正好有\(k\)条,使构造出的图点的个数\(N\len_5\)考虑\(k=2^t\)那么可以轻松构造出如下的图对于其他的情况可以考虑二进制拆分,如\(k=10\)时为了,使最短路长度固定加入点\(9\)对\(k=10^9\),只需构造\(80\)个点,可以......