Table of Contents
Use ol to add a book sales ranking list
4. Name p to make the logic clearer
任务
表格" >五、table标签,认识网页上的表格
六、用css样式,为表格加入边框
摘要" >七、caption标签,为表格添加标题和摘要
Home Web Front-end HTML Tutorial Basic HTML Tutorial: Understanding Tags (3)

Basic HTML Tutorial: Understanding Tags (3)

May 12, 2017 pm 01:56 PM

1. Use ul to add a news information list

1

2

3

4

5

6

7

8

9

10

11

1 <!DOCTYPE HTML>

 2 <html>

 3 <head>

 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

 5 <title> p标签</title>

 6 </head>

 7 <body>

 8

 9

10 </body>

11 </html>

Copy after login
Copy after login

When browsing the web, you will find that there are many information lists on the web page, such as news lists , picture list, as shown below.

从零开始学习html(三) 认识标签(第二部分)0

News list

从零开始学习html(三) 认识标签(第二部分)1

Picture list

These lists can be created using the ul-li tag Finish. ul-li is a list of information in no order.

Grammar:

1

2

3

4

5

<ul>

  <li>信息</li>

  <li>信息</li>

   ......

</ul>

Copy after login

Example:

1

2

3

4

5

<ul>

  <li>精彩少年</li>

  <li>美丽突然出现</li>

  <li>触动心灵的旋律</li>

</ul>

Copy after login

The default style of ul-li displayed on the web page is generally: each li has a dot in front of it, as shown below Shown:

从零开始学习html(三) 认识标签(第二部分)2

Let’s try it, enter

  • my first list information

    li stands for List in English, ol stands for ordered list in English, and ul stands for unordered list in English

    2. Use ol to add a book sales ranking list

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    1 <!DOCTYPE HTML>

     2 <html>

     3 <head>

     4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

     5 <title> p标签</title>

     6 </head>

     7 <body>

     8

     9

    10 </body>

    11 </html>

    Copy after login
    Copy after login

    Use ol to add a book sales ranking list

    What should you do if you want to display a sequential information list on a web page? ? For example, the book best-selling ranking list on Dangdang.com is

    as shown in the figure below. This kind of information display can use the

      tag to create an ordered list for display.

      从零开始学习html(三) 认识标签(第二部分)3

      Grammar:

      1

      2

      3

      4

      5

      <ol>

         <li>信息</li>

         <li>信息</li>

         ......

      </ol>

      Copy after login

      Example:

      The following is a popular course download ranking:

      1

      2

      3

      4

      5

      <ol>

         <li>前端开发面试心法 </li>

         <li>零基础学习html</li>

         <li>JavaScript全攻略</li>

      </ol>

      Copy after login

          

        The default style displayed on the web page is generally: each item of
      1. is preceded by a serial number, and the serial number starts from 1 by default, as shown in the following figure:

        从零开始学习html(三) 认识标签(第二部分)4

        Let’s try it, enter

        1

        2

        3

        4

        <ol>

           <li>我的第一个列表信息。</li>

           <li>我的第一个列表信息。</li>

        </ol>

        Copy after login

        on line 8 in the editor. Don’t forget the syntax of the

          tag.

          1

          2

          3

          4

          5

          6

          7

          <ol>

              <li>信息</li>

              <li>信息</li>

               ......

          </ol>

           

          三、认识p在排版中的作用

          Copy after login

          1

          2

          3

          4

          5

          6

          7

          8

          9

          10

          11

          12

          13

          14

          15

          16

          17

          18

          19

          20

          21

          1 <!DOCTYPE HTML>

           2 <html>

           3 <head>

           4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

           5 <title>p标签</title>

           6 </head>

           7 <body>

           8     <h2>热门课程排行榜</h2>

           9     <ol>

          10         <li>前端开发面试心法 </li>

          11         <li>零基础学习html</li>

          12         <li>javascript全攻略</li>

          13     </ol>

          14     <h2>最新课程排行</h2>

          15     <ol>

          16         <li>版本管理工具介绍—Git篇 </li>

          17         <li>Canvas绘图详解</li>

          18         <li>QQ5.0侧滑菜单</li>

          19     </ol>

          20 </body>

          21 </html>

          Copy after login

          During the web page creation process , you can divide some independent logical parts and put them in a

          tag. This

          tag acts like a container.

          Grammar:

          Determine the logical part:

          What is the logical part? It is a set of interrelated elements on the page. For example, an independent column section in a web page is a typical logical part.

          As shown in the figure below: The part marked with a red border in the figure is a logical part, and the

          tag can be used as a container.

          从零开始学习html(三) 认识标签(第二部分)5

          Let’s try it: use the p tag to divide the web page into independent sections

          Use the p tag in the editor to divide into independent logical parts. (There are many answers, let’s see who is the most concise)

          Don’t forget the syntax of the

          tag:

          Reference code : (Just one of them)

          1

          2

          3

          4

          5

          6

          7

          8

          9

          10

          11

          12

          13

          14

          15

          16

          17

          18

          19

          20

          21

          <p>

              <h2>热门课程排行榜</h2>

              <ol>

                  <li>前端开发面试心法 </li>

                  <li>零基础学习html</li>

                  <li>javascript全攻略</li>

              </ol>

          </p>

          <p>

              <h2>最新课程排行</h2>

              <ol>

                  <li>版本管理工具介绍—Git篇 </li>

                  <li>Canvas绘图详解</li>

                  <li>QQ5.0侧滑菜单</li>

              </ol>

          </p>

           

          一个html页面可以看成一个家,而一个p你们可以看成家的每个小房间,房间有了当然没什么效果,

          但是一个家必须分成一个个小房间才能多姿多彩,但每个房间里怎么装饰就得你们自己放东西,当然装饰就得交给css了,

          后面讲到<p class>大家就懂了。p标签就是一个框,将里面的东西框起来,然后通过css来使这个框按照所需要的样式显示出来。

          <p>就是分类,把一类东西放在一块,另一类东西放另一块。这样一目了然,就是<p>实现的。

          Copy after login

          p(pISION) As the name suggests, it divides the web page into blocks. p and span can be regarded as a container, or a box (Box model) .

          is equivalent to placing many containers on the browser screen. In order to look comfortable, each container must of course be arranged neatly and orderly - p positioning issues use CSS position, and FloatThe problem is using CSSfloat and the use of box model layout;

          In addition, after placing the container, it is necessary to put the content, such as lists, texts, images Wait, it's just like putting vegetables in a plate container. Of course, more dishes will look better. This is the role of CSS.

          We must integrate everything in our studies and learn to be a great Web front-end.


          4. Name p to make the logic clearer

          1

          2

          3

          4

          5

          6

          7

          8

          9

          10

          11

          12

          13

          14

          15

          16

          17

          18

          19

          20

          21

          22

          23

          24

          25

          1 <!DOCTYPE HTML>

           2 <html>

           3 <head>

           4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

           5 <title>p标签</title>

           6 </head>

           7 <body>

           8 <p>

           9    <h2>热门课程排行榜</h2>

          10     <ol>

          11        <li>前端开发面试心法 </li>

          12       <li>零基础学习html</li>

          13        <li>javascript全攻略</li>

          14     </ol>

          15 </p>

          16 <p>

          17     <h2>web前端开发导学课程</h2>

          18     <ul>

          19        <li>网页专业名词大扫盲 </li>

          20        <li>网站职位定位指南</li>

          21        <li>为您解密Yahoo网站制作流程</li>

          22     </ul>

          23 </p>

          24 </body>

          25 </html>

          Copy after login

          We put some tags into

          to create an independent logic part. In order to make the logic clearer, we can set a name for this independent logical part,

          用id属性来为

          提供唯一的名称,这个就像我们每个人都有一个身份证号,这个身份证号是唯一标识我们的身份的,也是必须唯一的。

          如下两图进行比较,如果设计师把两个图给你,哪个图你看上去能更快的理解呢?是不是右边的那幅图呢。

          从零开始学习html(三) 认识标签(第二部分)6

          语法:

          任务

          来试试给网页的独立的版块添加“标记”

          1、在编辑器中的第8行修改

          代码为

          2、在编辑器中的第16行修改

          代码为

          别忘了标记版块名称的语法:

          p相当于划分成一个个房间,id就是房间号了

          p的ID号是为了使用CSS的ID选择器,应用CSS样式,否则毫无意义。

          五、table标签,认识网页上的表格


          有时候我们需要在网页上展示一些数据,如某公司想在网页上展示公司的库存清单。如下表:

          从零开始学习html(三) 认识标签(第二部分)7

          想在网页上展示上述表格效果可以使用以下代码:

          从零开始学习html(三) 认识标签(第二部分)8

          创建表格的四个元素:

          table、tbody、tr、th、td

          1、

          :整个表格以标记开始、
          标记结束。

          2、…:当表格内容非常多时,表格会下载一点显示一点,但如果加上标签后,这个表格就要等表格内容全部下载完才会显示。

          3、…:表格的一行,所以有几对tr 表格就有几行。

          4、…:表格的一个单元格,一行中包含几对...,说明一行中就有几列。

          5、…:表格的头部的一个单元格,表格表头。

          6、表格中列的个数,取决于一行中数据单元格的个数。

          上述代码在浏览器中显示的默认的样式为:

          从零开始学习html(三) 认识标签(第二部分)9

          总结:

          1、table表格在没有添加css样式之前,在浏览器中显示是没有表格线的

          2、表头,也就是th标签中的文本默认为粗体并且居中显示

          任务

          来试试为数学成绩表添加一行内容

          在右部编辑器中的第25-29行输入下列代码:

          25.

          26. 三班

          27. 32

          28. 80

          29.

          结果图:

          从零开始学习html(三) 认识标签(第二部分)10

          1、表格的行标签的语法:

          2、一行中的单元格语法:

          1

          2

          3

          4

          5

          <tr>

             <td>…</td>

             <td>…</td>

             

          </tr>

          Copy after login

          tbody 防止那种因网速慢加载一点显示一点的情况,
          如果把网页比作一个女士
          加载样式的过程是化妆过程
          那么tbody就相当于屏蔽了化妆的过程直到
          女士化好妆在真正出来见人

          tr是“table row(表格行)”的缩写,用于表示一行的开始和结束。这也容易理解。
          td是“table data(表格数据)”的缩写,用于表示行中各个单元格(cell)的开始和结束。

          table 创建表格
          tbody全显示出来
          th表头
          tr每一行
          td每一个单元格

          表格标签表格完全下载完后才显示表格的一行标签表格表头标签。

          tr是行,td是表头,td是单元格内容;
          有几对tr就表示有几行,有几个td表示有几列。

          六、用css样式,为表格加入边框

          1

          2

          3

          4

          5

          6

          7

          8

          9

          10

          11

          12

          13

          14

          15

          16

          17

          18

          19

          20

          21

          22

          23

          24

          25

          26

          27

          28

          29

          30

          31

          32

          33

          34

          35

          36

          1 <!DOCTYPE HTML>

           2 <html>

           3 <head>

           4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

           5 <title>为表格添加边框</title>

           6 <style type="text/css">

           7 table tr td,th{border:1px solid #000;}

           8 </style>

           9 </head>

          10

          11 <body>

          12 <table summary="">

          13   <tr>

          14     <th>班级</th>

          15     <th>学生数</th>

          16     <th>平均成绩</th>

          17   </tr>

          18   <tr>

          19     <td>一班</td>

          20     <td>30</td>

          21     <td>89</td>

          22   </tr>

          23   <tr>

          24     <td>二班</td>

          25     <td>35</td>

          26     <td>85</td>

          27   </tr>

          28   <tr>

          29     <td>三班</td>

          30     <td>32</td>

          31     <td>80</td>

          32   </tr>

          33 </table>

          34

          35 </body>

          36 </html>

          Copy after login

          Table 表格在没有添加 css 样式之前,是没有边框的。我们为表格添加一些样式,为它添加边框。

          在代码编辑器中添加如下代码:

          1

          2

          3

          <style type="text/css">

          table tr td,th{border:1px solid #000;}

          </style>

          Copy after login

          上述代码是用 css 样式代码,为th,td单元格添加粗细为一个像素的黑色边框。

          结果窗口显示出结果样式:

          从零开始学习html(三) 认识标签(第二部分)11

          表格风格改变代码头尾:
          表格四元素:table tr td,th
          边框大小与颜色:{border:1px solid #000;}

          七、caption标签,为表格添加标题和摘要

          1

          2

          3

          4

          5

          6

          7

          8

          9

          10

          11

          12

          13

          14

          15

          16

          17

          18

          19

          20

          21

          22

          23

          24

          25

          26

          27

          28

          29

          30

          31

          32

          33

          34

          35

          36

          37

          38

          39

          40

          41

          1 <!DOCTYPE HTML>

           2 <html>

           3 <head>

           4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

           5 <title>认识table表标签</title>

           6 <style type="text/css">

           7 table tr td,th{

           8     border:1px solid #000;

           9 }

          10 </style>

          11 </head>

          12 <body>

          13 <table>

          14  

          15   <tr>

          16     <th>产品名称 </th>

          17     <th>品牌 </th>

          18     <th>库存量(个) </th>

          19     <th>入库时间 </th>

          20   </tr>

          21   <tr>

          22     <td>耳机 </td>

          23     <td>联想 </td>

          24     <td>500</td>

          25     <td>2013-1-2</td>

          26   </tr>

          27   <tr>

          28     <td>U盘 </td>

          29     <td>金士顿 </td>

          30     <td>120</td>

          31     <td>2013-8-10</td>

          32   </tr>

          33   <tr>

          34     <td>U盘 </td>

          35     <td>爱国者 </td>

          36     <td>133</td>

          37     <td>2013-3-25</td>

          38   </tr>

          39 </table>

          40 </body>

          41 </html>

          Copy after login

          表格还是需要添加一些标签进行优化,可以添加标题和摘要。代码如下:

          从零开始学习html(三) 认识标签(第二部分)12

          摘要

          摘要的内容是不会在浏览器中显示出来的。它的作用是增加表格的可读性(语义化),使搜索引擎更好的读懂表格内容,还可以使屏幕阅读器更好的帮助特殊用户读取表格内容。

          语法:

          表格的一个单元格,有几个就有几列。
          简介文本">

          标题

          用以描述表格内容,标题的显示位置:表格上方。

          语法:

          1

          2

          3

          4

          5

          6

          7

          8

          9

          <table>

              <caption>标题文本</caption>

              <tr>

                  <td>…</td>

                  <td>…</td>

                  

              </tr>

          </table>

          Copy after login

          来试试,为文章添加标题

          1. 在编辑器中为表格添加摘要,摘要的内容为“本表格记录2012年到2013年库存记录,记录包括U盘和耳机库存量”。

          2. 在编辑器中为表格添加标题,标题的内容为“2012年到2013年库存记录”。

          别忘了caption标签的语法

          1

          <caption>...</caption>

          Copy after login

          标题,肯定在最上面,也不能跑到表外面吧。所以在

          下一行的位置写就行。
          备注,是这个表的备注,所以,紧跟着table吧。

          table的summary属性目的是语义化标签,是为了SEO,和完全是两回事,

          因为浏览器(除了ie),百度,谷歌的引擎是不会读你的注释文字的。

          【相关推荐】

          1. 免费html在线视频教程

          2. html开发手册

          3. php.cn原创html5视频教程

          The above is the detailed content of Basic HTML Tutorial: Understanding Tags (3). For more information, please follow other related articles on the PHP Chinese website!

          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)

          Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

          Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

          Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

          This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

          HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

          Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

          HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

          Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

          HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

          Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

          HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

          Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

          Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

          Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

          HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

          Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

          See all articles