1.标签的style属性 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 <!DOCTYPE html > <html lang ="en" > <head > <meta charset ="UTF-8" > <meta name ="viewport" content ="width=device-width, initial-scale=1.0" > <title > Document</title > <style > h1 { text-align : center; } </style > <link rel ="stylesheet" type ="text/css" href ="styles.css" > </head > <body > <h1 > 居中对齐的标题</h1 > <h1 > 黄色标题</h1 > <p > 红色段落</p > <a href ="https://th.bing.com/th/id/R.e40690c18cdae70edc9396b13522185c?rik=sVz9lHDz3lEsxg&pid=ImgRaw&r=0" style ="text-decoration: none;" > 这是一个好图片</a > </body > </html >
2.标题和文本大小对应和空格换行空行等问题 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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 <h1 > 这是1号标题</h1 > <font size ="6" > 这是6号字体文本</font > <h2 > 这是2号标题</h2 > <font size ="5" > 这是5号字体文本</font > <h3 > 这是3号标题</h3 > <font size ="4" > 这是4号字体文本</font > <h4 > 这是4号标题</h4 > <font size ="3" > 这是3号字体文本</font > <h5 > 这是5号标题</h5 > <font size ="2" > 这是2号字体文本</font > <h6 > 这是6号标题</h6 > <font size ="1" > 这是1号字体文本</font > <p > 这是一个段落</p > <p > 这是另一个段落</p > <p > 春眠不觉晓, 处处闻啼鸟。 夜来风雨声, 花落知多少。 </p > <p > 注意,浏览器忽略了源代码中的排版(省略了多余的空格和换行)。</p > <pre > 春眠不觉晓, 处处闻啼鸟。 夜来风雨声, 花落知多少。 </pre > <p > 该段落文字从左到右显示。</p > <p > <bdo dir ="rtl" > 该段落文字从右到左显示。</bdo > </p > <q > 世界很美</q > <p > My favorite color is <del > blue</del > <ins > red</ins > !</p > 此例演示如何标记删除文本和插入文本。
3.a标签和它的单双向锚点 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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 <!DOCTYPE html > <html lang ="en" > <head > <meta charset ="UTF-8" > <title > Title</title > </head > <body > <a href ="https://download-cdn.jetbrains.com/cpp/CLion-2023.2.2.exe" download > 下载Clion</a > <a href ="5.列表.html" > 列表</a > <a href ="E:\WebStormProject\html5\5.列表.html" > 绝对路径列表</a > <a href ="http://www.baidu.com" > 百度</a > <a href ="5.列表.html" target ="_blank" > 列表</a > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <b <a href ="https://www.jxust.edu.cn/" > <img src ="https://th.bing.com/th/id/R.cbe5d465d13f9e3d47bf01dfef14e3f9?rik=eS9ZwVCDEEfFEA&pid=ImgRaw&r=0" alt ="失败了" title ="oh nice" > </a > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <a href ="https://www.baidu.com" target ="_blank" > <img src ="https://th.bing.com/th/id/R.45c5d20f24f31d725c464126d640e46a?rik=amBpLdzrB9zDQw&riu=http%3a%2f%2ftu.52guzhuang.com%2fd%2ffile%2fp%2f2016-11-14%2fa2zgrfbhjdu7743.jpg&ehk=jz%2bScVdYDISwvDKqpuO2GFfpojC5bTUd9bgAq%2bpTGSU%3d&risl=&pid=ImgRaw&r=0" title ="大长腿美女姐姐" border ="5" align ="right" > </a <br /> <a href ="#回去家乡看看" id ="去看看美女姐姐" > 回去家乡看看</a > <pre > 雁门太守行 李贺〔唐代〕 黑云压城城欲摧,甲光向日金鳞开。 角声满天秋色里,塞上燕脂凝夜紫。 半卷红旗临易水,霜重鼓寒声不起。 报君黄金台上意,提携玉龙为君死。 </pre > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <h2 id ="华为mate60pro" > 华为mate60pro 遥遥领先 遥遥领先 遥遥领先!</h2 > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <br > <a href ="#华为mate60pro" > 华为mate60pro</a > <a href ="#去看看美女姐姐" name ="回去家乡看看" > 去看看美女姐姐</a > <a href ="#" > 开头1</a > <a href ="" > 开头2</a > </body > </html >
4.基础语法 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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 <!DOCTYPE html > <html lang ="en" > <head > <meta charset ="UTF-8" > <title > 标题</title > <link rel ="stylesheet" href ="引入我们的css文件的路径" > <script src ="引入的js文件路径" type ="text/javascript" charset ="utf-8" > </script > </head > <body > hello </body > </html > ```## 3.标题和水平线 ```html <!DOCTYPE html > <html lang ="en" > <head > <meta charset ="UTF-8" > <title > Title</title > </head > <body bgcolor ="#ffc0cb" text ="blue" > Hello <h1 > Hello</h1 > <h2 > Hello</h2 > <h3 > Hello</h3 > <h4 > Hello</h4 > <h5 > Hello</h5 > <h6 > Hello</h6 > <hr width ="50%" align ="left" size ="5" /> <hr width ="500px" align ="right" size ="10" /> </body > </html >
5.段落和换行 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 <!DOCTYPE html > <html lang ="en" > <head > <meta charset ="UTF-8" > <title > Title</title > </head > <body > <p align ="left" > 这是段落1</p > <hr /> <p align ="right" > 这是段落2</p > <hr /> <p align ="center" > 这是段落3</p > <hr /> <p align > 这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行Hello 这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行Hello这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行 这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行 </p > <p align ="justify" > 这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行Hello 这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行Hello这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行 这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行这是段落4多行 </p > <hr /> <hr /> Hello<br /> World </body > </html >
6.列表 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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 <!DOCTYPE html > <html lang ="en" > <head > <meta charset ="UTF-8" > <title > Title</title > </head > <body > <h2 > 无序列表</h2 > <ul > <li > 张三</li > <li > 李四</li > <li > 王五</li > </ul > <hr /> <ul type ="square" > <li > 张三</li > <li > 李四</li > <li > 王五</li > </ul > <hr /> <ul type ="circle" > <li > 张三</li > <li > 李四</li > <li > 王五</li > </ul > <h2 > 有序列表</h2 > <ol > <li > 张三</li > <li > 李四</li > <li > 王五</li > </ol > <hr /> <ol type ="a" > <li > 张三</li > <li > 李四</li > <li > 王五</li > </ol > <ol type ="A" > <li > 张三</li > <li > 李四</li > <li > 王五</li > </ol > <hr /> <ol type ="i" > <li > 张三</li > <li > 李四</li > <li > 王五</li > </ol > <ol type ="I" > <li > 张三</li > <li > 李四</li > <li > 王五</li > </ol > </body > </html >
自定义列表 场景: 在网页的底部导航中通常会使用自定义列表实现。
标签组成:
标签名
说明
dl
表示自定义列表的整体,用于包裹dt/dd标签
dt
表示自定义列表的主题
dd
表示自定义列表的针对主题的每一项内容
显示特点: • dd前会默认显示缩进效果
注意点: • dl标签中只允许包含dt/dd标签 • dt/dd标签可以包含任意内容
小结 有序列表由几个标签组成?分别表示什么?
• ol标签:表示有序列表的整体 • li标签:表示有序列表的每一项
有序列表标签的嵌套规范是什么?
• ol标签中只允许嵌套li标签 • li标签中可以嵌套任意内容
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 <!DOCTYPE html > <html lang ="en" > <head > <meta charset ="UTF-8" > <meta http-equiv ="X-UA-Compatible" content ="IE=edge" > <meta name ="viewport" content ="width=device-width, initial-scale=1.0" > <title > Document</title > </head > <body > <dl > <dt > 帮助中心</dt > <dd > 账户管理</dd > <dd > 购物指南</dd > </dl > </body > </html >
7.div和span 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 <!DOCTYPE html > <html lang ="en" > <head > <meta charset ="UTF-8" > <title > Title</title > </head > <body > <div align ="center" > 层块级元素div,标签自动换行 </div > <div > 层块级元素div,标签自动换行<br /> 自动调整大小 </div > <hr /> <span > 名字张三</span > </body > </html >
8.格式化标签 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 42 43 44 45 46 <!DOCTYPE html > <html lang ="en" > <head > <meta charset ="UTF-8" > <title > Title</title > </head > <body > 你好 <br /> <font color ="red" size ="7" face ="楷体" > 你好</font > <hr /> Hello World <pre > Hello World</pre > <hr /> <p > <b > 粗体</b > </p > <p > <strong > 粗体</strong > </p > <hr /> <p > <i > 斜体</i > </p > <p > <u > 下划体</u > </p > <p > <del > 中划体</del > </p > <p > H<sub > 2</sub > O</p > <p > 2<sup > 2</sup > </p > </body > </html >
9.图片 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 <!DOCTYPE html > <html lang ="en" > <head > <meta charset ="UTF-8" > <title > Title</title > </head > <body > <h2 > 本地资源</h2 > <img src ="img/jxust.jpg" > <br /> <h2 > 网络资源</h2 > <a href ="https://www.baidu.com" target ="_blank" > <img src ="https://www.baidu.com/img/pcguoqing_fc97127958bbaff5dbb6b51b665665ea.gif" title ="百度" border ="2" align ="right" > </a > <h2 > 显示失败</h2 > <img src ="img/jxust1.jpg" alt ="加载失败" > <br /> </body > </html >
10.表格 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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 <!DOCTYPE html > <html lang ="en" > <head > <meta charset ="UTF-8" > <title > Title</title > </head > <body > <table border ="1" width ="500px" style ="border-collapse: collapse" align ="center" height ="300px" > <tr > <th > 班级</th > <th > 姓名</th > <th > 年龄</th > <th > 性别</th > </tr > <tr align ="center" valign ="top" bgcolor ="#faebd7" > <td rowspan ="2" > 101</td > <td > 张三</td > <td > 18</td > <td > 男</td > </tr > <tr align ="right" > <td > 李四</td > <td > 18</td > <td > 男</td > </tr > <tr align ="left" > <td > 103</td > <td > 王五</td > <td > 18</td > <td > 男</td > </tr > </table > <hr /> <h2 > 纵向合并</h2 > <table border ="1" width ="500px" style ="border-collapse: collapse" align ="center" > <tr > <th > 班级</th > <th > 姓名</th > <th > 年龄</th > <th > 性别</th > </tr > <tr align ="center" > <td rowspan ="2" > 101</td > <td > 张三</td > <td > 18</td > <td > 男</td > </tr > <tr align ="center" > <td > 李四</td > <td > 18</td > <td > 男</td > </tr > <tr align ="center" > <td > 103</td > <td > 王五</td > <td > 18</td > <td > 男</td > </tr > </table > <hr > <h2 > 横向合并</h2 > <table border ="1" width ="500px" style ="border-collapse: collapse" align ="center" > <tr > <th colspan ="2" > 班级+姓名</th > <th > 年龄</th > <th > 性别</th > </tr > <tr align ="center" > <td > 101</td > <td > 张三</td > <td > 18</td > <td > 男</td > </tr > <tr align ="center" > <td > 102</td > <td > 李四</td > <td > 18</td > <td > 男</td > </tr > <tr align ="center" > <td > 103</td > <td > 王五</td > <td > 18</td > <td > 男</td > </tr > </table > </body > </html >
11.表单 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 <!DOCTYPE html > <html lang ="en" > <head > <meta charset ="UTF-8" > <title > Title</title > </head > <body > <form action ="https://www.baidu.com" > 姓名:<input type ="text" > <button > 提交</button > </form > <form > 姓名:<input type ="text" name ="username" > <button > 提交</button > </form > </body > </html >
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 <!DOCTYPE html > <html lang ="en" > <head > <meta charset ="UTF-8" > <title > Title</title > </head > <body > 只读文本框: <input type ="text" value ="张三" readonly > <br > 限制字数文本框: <input type ="text" value ="张三" maxlength ="10" > <br > 密码框:<input type ="password" > <br > 单选框:<input type ="radio" value ="man" name ="sex" > 男 <input type ="radio" value ="woman" name ="sex" > 女 复选框:<input type ="checkbox" value ="1" name ="cb" > 1 <input type ="checkbox" value ="2" name ="cb" > 2 <input type ="checkbox" value ="3" name ="cb" > 3<br > 文件域:<input type ="file" > <br > 隐藏域:<input type ="hidden" value ="admin" > <br > 普通按钮: <input type ="button" value ="普通按钮" > 提交按钮 <input type ="submit" value ="提交按钮" > 重置按钮 <input type ="reset" value ="重置按钮" > <br > 日期框 <input type ="date" > </body > </html >
13.textarea和label 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 <!DOCTYPE html > <html lang ="en" > <head > <meta charset ="UTF-8" > <title > Title</title > </head > <body > 姓名:<input type ="text" name ="uname" /> <br > 简介:<textarea cols ="30" rows ="10" > </textarea > <hr > <label for ="uanme" > 姓名:</label > <input id ="uanme" type ="text" name ="uname" /> <br > </body > </html >
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 <!DOCTYPE html > <html lang ="en" > <head > <meta charset ="UTF-8" > <title > Title</title > </head > <body > <form action ="https://www.baidu.com" method ="get" > <input type ="text" name ="uname" > <input type ="button" value ="普通按钮" > <input type ="submit" value ="提交按钮" > <input type ="reset" value ="重置按钮" > <hr > <button type ="button" > 普通按钮(能加图标诶!)</button > <button type ="submit" > 提交按钮</button > <button type ="reset" > 重置按钮</button > </form > </body > </html >
15.下拉框 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 <!DOCTYPE html > <html lang ="en" > <head > <meta charset ="UTF-8" > <title > Title</title > </head > <body > <select name ="city" > <option > 上海</option > <option > 北京</option > <option > 深圳</option > </select > <select name ="city" > <option value ="" > 请选择城市</option > <option > 上海</option > <option selected = "selected" > 北京</option > <option > 深圳</option > </select > </body > </html >
16.常用字符实体和标签分类 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 <!DOCTYPE html > <html lang ="en" > <head > <meta charset ="UTF-8" > <title > Title</title > </head > <body > <h2 > 你        好</h2 > <h2 > 你 好</h2 > 版权声明:© <h2 > <h2>你  好<h2></h2 > <br > 版权声明:© </body > </html >
17.杂记
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 <!DOCTYPE html > <html > <head > <meta charset ="utf-8" > <title > 菜鸟教程(runoob.com)</title > <style > #example1 { border : 20px solid #e61616 ; padding : 100px 40px ; background : #716363 ; width : 900px ; height : 1000px ; border-radius : 25px ; } #example2 { border : 20px solid red; padding : 100px ; border-radius : 100px 20px ; } #example3 { border : 20px solid red; padding : 100px ; border-radius : 100px 20px ; } .example4 { border : 20px solid red; padding : 100px ; border-radius : 100px 20px ; } </style > </head > <body > <div id ="example1" > <p > border-radius 属性允许您为元素添加圆角边框!</p > </div > <br > <br > <div id ="example2" > <p > 如果设置了两个值,第一个用于左上角和右下角,第二个用于右上角和左下角。</p > </div > <div id ="example2" > <p > 潘多拉魔盒打开。</p > </div > <div id ="example3" > <p > 如果设置了两个值,第一个用于左上角和右下角,第二个用于右上角和左下角。</p > </div > <div class ="example4" > <p > 我知道自己过去很贱。</p > </div > <div class ="example4" title ="美女的块块" dir ="" > <p > 我知道自己过去很贱。</p > </div > </body > </html >