Table of Contents
HTML table
HTML list
Home Web Front-end HTML Tutorial HTML tables and lists_html/css_WEB-ITnose

HTML tables and lists_html/css_WEB-ITnose

Jun 24, 2016 am 11:50 AM

HTML table

A table is actually a lot of small cells, and these small cells are arranged in an orderly manner. They have many rows and columns. These things composed of many rows and columns are called tables, and tables are defined by the

tag. The rows in the
tag are the tags, and the columns are the
tags. Rows must be defined before columns can be defined. Because in html, each column is in a row.

The following table summarizes some commonly used tags:

below the above comment are written anyway. A very small table will appear, but the text written in will not be displayed

So in HTML, writing a table must be written line by line.

The tag contains
表格 描述
定义表格
定义表格标题
定义表格的表头
定义表格的行
定义表格的单元
定义表格的页眉
定义表格的主体
定义表格的页脚
定义表格的列属性

First define a simple table:

You can see it after running

<!DOCTYPE html><html>    <head>        <title></title>        <meta charset="utf-8">    </head>    <body>        <table border="1">            <tr>                <td>水果</td>                <td>水果</td>                <td>水果</td>            </tr>    <!-- 下面将td与tr反正写了,是不会构成表的 -->            <td>                <tr>asd</tr>                <tr>asd</tr>                <tr>asd</tr>                <tr>asd</tr>            </td>        </table>    </body></html>
Copy after login

As you can see, the

and

Table without borders

A table without borders is actually in the

tag without adding Property border. The border attribute represents the border of the table. If no attribute is added, the default border="0" will be used. However, if there is no border, sometimes you will not be able to tell that it is a table. So sometimes a 1-pixel border is set for border="1px". Temporarily remove the border attribute and complete a table without borders

<!DOCTYPE html><html>    <head>        <title></title>        <meta charset="utf-8">    </head>    <body>        <table>            <tr>                <td>呵呵</td>                <td>哈哈</td>                <td>嘻嘻</td>            </tr>            <tr>                <td>嘿嘿</td>                <td>嘎嘎</td>                <td>噗噗</td>            </tr>            <tr>                <td>啊啊</td>                <td>哦哦</td>                <td>噢噢</td>            </tr>        </table>    </body></html>
Copy after login


in the table The header

You can also add a header to the table, using the

tag. For the sake of better appearance, we still add the border:

<!DOCTYPE html><html>    <head>        <title></title>        <meta charset="utf-8">    </head>    <body>        <table border="1">            <tr>                <th>人物</th>                <th>介绍</th>                <th>产品</th>            </tr>            <tr>                <td>史蒂夫&middot;保罗&middot;乔布斯</td>                <td>苹果CEO</td>                <td>Apple系列</td>            </tr>            <tr>                <td>丹尼斯&middot;里奇</td>                <td>C语言之父</td>                <td>C语言</td>            </tr>            <tr>                <td>比尔&middot;盖茨</td>                <td>微软CEO</td>                <td>Windows系统</td>            </tr>        </table>    </body></html>
Copy after login

You can also set the margins within the table The cellpadding attribute
can also set the cell margins cellspacing attribute

<table border="1" cellpadding="10" cellspacing="10">    <tr>        <td>xxx</td>    </tr></table>
Copy after login


Table with title

I am the header
tag, The tag is also in the

<table border="1" cellpadding="10" cellspacing="10">            <caption>xxx表</caption>            <tr>                <td>xxx</td>            </tr></table>
Copy after login

The color bgcolor attribute in the table

<table border="1" bgcolor="red">    <tr>        <td>xxx</td>    </tr></table>
Copy after login


The align attributes of cell content arrangement are center, left, right

<table border="1" align="center">    <caption>xxx表</caption>    <tr>        <td>xxx</td>    </tr></table>
Copy after login

Colspan attribute of cells across rows and columns, to be precise, merged cells

<table border="1">    <caption>xxx表</caption>    <tr>        <td colspan="2">xxx</td>        <td>xxx</td>    </tr>    <tr>        <td>xxx</td>        <td>xxx</td>        <td>xxx</td>    </tr></table>
Copy after login

HTML list

A list is just like the titles in word, counting down.

The subscripts are tags that control the title

标签 描述
    有序列表
      无序列表
    • 列表项
      列表
      列表项
      描述

      这些列表还分有序列表,无序列表和自定义列表。

      无序列表

      • 属性:disc:实体圆、circle:空心圆、square:实体方块

        <!DOCTYPE html><html>    <head>        <title></title>        <meta charset="utf-8">    </head>    <body>    <!-- 无序列表默认属性是disc,disc定义一个实体圆,所以disc不用刻意去设置 -->        <ul>            <li>我是第一个</li>            <li>我是第二个</li>            <li>我是第三个</li>        </ul>    <!-- 这些属性都是通过type来定义的,circle是定义一个空心圆 -->        <ul type="circle">            <li>我是第一个</li>            <li>我是第二个</li>            <li>我是第三个</li>        </ul>    <!-- square定义实体方块 -->        <ul type="square">            <li>我是第一个</li>            <li>我是第二个</li>            <li>我是第三个</li>        </ul>    </body></html>
        Copy after login

        有序列表

        1. 属性:A、a、l、i、start

          <!DOCTYPE html><html>    <head>        <title></title>        <meta charset="utf-8">    </head>    <body>    <!-- 有序列表默认是数字往下计数的 -->        <ol>            <li>我是第一个</li>            <li>我是第二个</li>            <li>我是第三个</li>        </ol>    <!-- 定义A,就是按照大写字母来计数的,当然了,不能直接定义B,它不是不会从B开始数的 -->        <ol type="A">            <li>我是第一个</li>            <li>我是第二个</li>            <li>我是第三个</li>        </ol>    <!-- 定义a,就是安装小写字母开始计数的 -->        <ol type="a">            <li>我是第一个</li>            <li>我是第二个</li>            <li>我是第三个</li>        </ol>    <!-- 定义I,就是按照大写罗马数字计数的 -->        <ol type="I">            <li>我是第一个</li>            <li>我是第二个</li>            <li>我是第三个</li>        </ol>    <!-- 定义i,就是按照大写罗马数字计数的 -->        <ol type="i">            <li>我是第一个</li>            <li>我是第二个</li>            <li>我是第三个</li>        </ol>    <!-- start属性,就是按照从多少数来计数,比如我想从3开始计数。start属性只能定义数字,不支持英文字母哦。 -->        <ol start="3">            <li>我是第一个</li>            <li>我是第二个</li>            <li>我是第三个</li>        </ol>    </body></html>
          Copy after login

          嵌套列表

            1. 嵌套列表就是有序列表套无序列表,无序套有序的呗。

              <!DOCTYPE html><html>    <head>        <title></title>        <meta charset="utf-8">    </head>    <body>        <ol>            <li>人物</li>            <ul>                <li>斯蒂芬&middot;保罗&middot;乔布斯</li>                <li>丹尼斯&middot;里奇</li>                <li>比尔&middot;盖茨</li>            </ul>                        <li>动物</li>            <ul>                <li>猫</li>                <li>狗</li>                <li>熊</li>            </ul>        </ol>                </body></html>
              Copy after login

              自定义列表

              自定义的列表,就是没有有序、无序的点。后期可以用CSS样式来加工修改。也是比较常用的操作

              <!DOCTYPE html><html>    <head>        <title></title>        <meta charset="utf-8">    </head>    <body>        <dl>            <li>我是标题</li>            <dt>                <dd>我是正文,我必须长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长</dd>            </dt>        </dl>                </body></html>
              Copy after login

              Statement of this Website
              The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

              Hot AI Tools

              Undresser.AI Undress

              Undresser.AI Undress

              AI-powered app for creating realistic nude photos

              AI Clothes Remover

              AI Clothes Remover

              Online AI tool for removing clothes from photos.

              Undress AI Tool

              Undress AI Tool

              Undress images for free

              Clothoff.io

              Clothoff.io

              AI clothes remover

              Video Face Swap

              Video Face Swap

              Swap faces in any video effortlessly with our completely free AI face swap tool!

              Hot Tools

              Notepad++7.3.1

              Notepad++7.3.1

              Easy-to-use and free code editor

              SublimeText3 Chinese version

              SublimeText3 Chinese version

              Chinese version, very easy to use

              Zend Studio 13.0.1

              Zend Studio 13.0.1

              Powerful PHP integrated development environment

              Dreamweaver CS6

              Dreamweaver CS6

              Visual web development tools

              SublimeText3 Mac version

              SublimeText3 Mac version

              God-level code editing software (SublimeText3)

              Hot Topics

              Java Tutorial
              1664
              14
              PHP Tutorial
              1268
              29
              C# Tutorial
              1246
              24
              Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

              WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

              HTML: The Structure, CSS: The Style, JavaScript: The Behavior HTML: The Structure, CSS: The Style, JavaScript: The Behavior Apr 18, 2025 am 12:09 AM

              The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

              The Future of HTML, CSS, and JavaScript: Web Development Trends The Future of HTML, CSS, and JavaScript: Web Development Trends Apr 19, 2025 am 12:02 AM

              The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

              The Future of HTML: Evolution and Trends in Web Design The Future of HTML: Evolution and Trends in Web Design Apr 17, 2025 am 12:12 AM

              The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

              HTML vs. CSS vs. JavaScript: A Comparative Overview HTML vs. CSS vs. JavaScript: A Comparative Overview Apr 16, 2025 am 12:04 AM

              The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

              HTML: Building the Structure of Web Pages HTML: Building the Structure of Web Pages Apr 14, 2025 am 12:14 AM

              HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

              The Role of HTML: Structuring Web Content The Role of HTML: Structuring Web Content Apr 11, 2025 am 12:12 AM

              The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.

              HTML: Is It a Programming Language or Something Else? HTML: Is It a Programming Language or Something Else? Apr 15, 2025 am 12:13 AM

              HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

              See all articles