• HTML常用标签的简单用法


    目录

    1.常用标签

    1.1 注释标签

    1.1标题标签 - 块级元素

    1.2 段落标签 - 块级元素

    1.3 格式化标签 - 行内元素

    1.4 图片标签

    1.5 超链接标签

    1.6 表格标签

    1.7 列表标签

    1.7 表单标签

    1.8 无语义标签 - div & span

    2.综合案例

    2.1 展示简历信息

    2.2 填写简历信息


    1.常用标签

    注释标签、标题标签、段落标签、换行标签、格式化标签、图片标签、超链接标签、表格标签、表单标签、无语义标签....

    1.1 注释标签

     

    1.1标题标签 - 块级元素

    1. html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
    6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    7. <title> 标题标签 title>
    8. head>
    9. <body bgcolor=pink>
    10. <h1>一级标题h1>
    11. <h2>二级标题h2>
    12. <h3>三级标题h3>
    13. <h4>四级标题h4>
    14. <h5>五级标题h5>
    15. <h6>六级标题h6>
    16. body>
    17. html>

     h1 ~ h6,数字越小,字体就越大越粗;数字越大,字体就越小越细。

    1.2 段落标签 - 块级元素

    1. html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
    6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    7. <title>Documenttitle>
    8. head>
    9. <body>
    10. <p>这是一个段落 Lorem ipsum dolor sit, amet consectetur adipisicing elit. <br> Architecto tenetur nihil qui id quia magnam. Consectetur consequuntur omnis a excepturi totam ex nobis deserunt, cupiditate voluptatem, itaque, impedit ad veniam.p>
    11. <p>这是一个段落 Lorem ipsum dolor sit, amet consectetur adipisicing elit.    Architecto tenetur nihil qui id quia magnam. Consectetur consequuntur omnis a excepturi totam ex nobis deserunt, cupiditate voluptatem, itaque, impedit ad veniam.p>
    12. <p>这是一个段落 Lorem ipsum dolor sit, amet consectetur adipisicing elit. Architecto tenetur nihil qui id quia magnam. Consectetur consequuntur omnis a excepturi totam ex nobis deserunt, cupiditate voluptatem, itaque, impedit ad veniam.p>
    13. <p>这是一个段落 Lorem ipsum dolor sit, amet consectetur adipisicing elit. Architecto tenetur nihil qui id quia magnam. Consectetur consequuntur omnis a excepturi totam ex nobis deserunt, cupiditate voluptatem, itaque, impedit ad veniam.p>
    14. <p>这是一个段落 Lorem ipsum dolor sit, amet consectetur adipisicing elit. Architecto tenetur nihil qui id quia magnam. Consectetur consequuntur omnis a excepturi totam ex nobis deserunt, cupiditate voluptatem, itaque, impedit ad veniam.p>
    15. body>
    16. html>

    1.排版测试,,使用 lorem ;

    2.列编辑:多行排版测试,同一列,按住 alt,鼠标往下点;

    3.html 会忽略换行和空格,所以需要使用标签 -
    换行标签 ,   空格。

    1.3 格式化标签 - 行内元素

    1. html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
    6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    7. <title>Documenttitle>
    8. head>
    9. <body>
    10. <strong>加粗1strong>
    11. <b>加粗2b>
    12. <em>倾斜1em>
    13. <i>倾斜2i>
    14. <del>删除线1del>
    15. <s>删除线2s>
    16. <ins>下划线1ins>
    17. <u>下划线2u>
    18. body>
    19. html>

    1.4 图片标签

    1. html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
    6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    7. <title>Documenttitle>
    8. head>
    9. <body>
    10. <img src="https://i03piccdn.sogoucdn.com/65969965190dcae3"
    11. alt="ikun" title="鸡你太美"
    12. width="400px"
    13. height="300px">
    14. body>
    15. html>

    图片路径正常:                                                      图片路径有问题: 

     

    1. src 里面既可以写相对路径,也可以写绝对路径,但是一般不写绝对路径,常用写法,是在 src 里面写网络路径,也就是我们在百度里查看一张图片,右击复制图片地址,将其放入 src 中。

    2. 如果路径有问题,图片就会出现图裂了的图标,当图片加载不出来时,就会显示 alt 里面的内容。

    3. title:鼠标放在图片上,显示 title 里面的内容。

    4. 图片大小,可以通过 width、height 来设置。

    1.5 超链接标签

    href 里面可以写一个完整的网址,可以跳转到任意的网站:

    1. html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
    6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    7. <title>Documenttitle>
    8. head>
    9. <body>
    10. <a href="https://www.sogou.com">这是一个超链接a>
    11. body>
    12. html>

    href 里面也可以只写一个 文件名/相对路径 ,表示在当前网站内跳转:

     1.html 文件

    1. html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
    6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    7. <title>Documenttitle>
    8. head>
    9. <body>
    10. <a href="hello.html" target="_blank">跳转到 hello.htmla>
    11. body>
    12. html>

    hello.html 文件 

    1. html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
    6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    7. <title>Documenttitle>
    8. head>
    9. <body>
    10. <a href="1.html">跳转到 1.htmla>
    11. body>
    12. html>

    1. 如果 a 标签里只有 href,那么就只能在当前页面跳转,想要跳转到新的页面,需要设置 target = "_blank" .

    2. href 里面还可以写成 # ,表示不进行任何跳转;还可以写成其他类型的文件,这个时候会触发浏览器的 "下载" 功能。

    1.6 表格标签

    table:表示整个表格;

    tr:表示表格中的一行;

    td:表示表格中的一个单元格;

    th:也表示单元格,用来表示表头的单元格,字体相对更粗,文字会居中。

    1. html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
    6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    7. <title>表格title>
    8. <style>
    9. /* CSS 代码 */
    10. td {
    11. text-align: center;
    12. }
    13. style>
    14. head>
    15. <body>
    16. <table border="1px" width = "500px" height = "400px" cellspacing = "0">
    17. <tr>
    18. <th>姓名 th>
    19. <th>性别th>
    20. <th>年龄th>
    21. tr>
    22. <tr>
    23. <td>张三td>
    24. <td>td>
    25. <td>13td>
    26. tr>
    27. <tr>
    28. <td>李四td>
    29. <td>td>
    30. <td>23td>
    31. tr>
    32. table>
    33. body>
    34. html>

    1. td 单元格里的内容,想要通过纯 html 是做不到的,所以可以搭配 CSS;

    2. 表格有一个边框,单元格也有一个边框,这样的表格看起来就有两条边框了,要想只有一条边框,可以通过设置 cellspacing = 0 来做到。

    1.7 列表标签

    有序列表:ol   -   ordered list

    无序列表:ul   -   unordered list

    列表项:li

    1. html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
    6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    7. <title>Documenttitle>
    8. head>
    9. <body>
    10. <ol>
    11. <li>李华li>
    12. <li>张三li>
    13. <li>李四li>
    14. <li>王五li>
    15. ol>
    16. <ul>
    17. <li>李华li>
    18. <li>张三li>
    19. <li>李四li>
    20. <li>王五li>
    21. ul>
    22. body>
    23. html>

    1.7 表单标签

    1. html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
    6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    7. <title>Documenttitle>
    8. head>
    9. <body>
    10. <input type="text">
    11. <br>
    12. <input type="password">
    13. <br>
    14. <input type="radio" name="gender" id="male"><label for="male">label>
    15. <input type="radio" name="gender" id="female" checked = "checked"><label for="female">label>
    16. <br>
    17. <input type="checkbox"> 吃饭
    18. <input type="checkbox"> 睡觉
    19. <input type="checkbox"> 打游戏
    20. <br>
    21. <input type="button" value = "这是一个按钮">
    22. <br>
    23. <input type="file">
    24. <br>
    25. <select>
    26. <option>北京option>
    27. <option>上海option>
    28. <option selected = "selected">广州option>
    29. <option>深圳option>
    30. select>
    31. <br>
    32. <textarea cols="30" rows="10">textarea>
    33. body>
    34. html>

    1. 单行输入框:type = "text";

    2. 密码框:type = "password";

    3. 单选框:type = "radio" ,设置 name 属性等于相同的值,可以做到排他;如果单选框按太小了,点不到,可以设置点文字也生效,通过 label 标签,id媒介,将文字和单选框绑定在一起;如果想要默认情况下选择一个,就在想设置的地方,添加 checked = "checked"

    4. 复选框:type = "checkbox";

    5. 按钮:type = "button" ,还可以给按钮设置 value;

    6.文件选择器:type = "file";

    7. 下拉菜单:select,option,可以通过设置 selected = "selected" 将某个选项设为默认被选中;

    8. 多行编辑框:textarea。

    1.8 无语义标签 - div & span

    1.无语义标签没有特定的应用场景,可以适用于大部分的场景;

    2.前面介绍的标签中,除了 input 系列标签无法用无语义标签代替,其他的标签基本上都可以使用 div / span 来代替。

    3.区别:div 是一个 "大盒子" ,属于块级元素,独占一行;span 是一个 "小盒子",属于行内元素,不独占一行。

    2.综合案例

    2.1 展示简历信息

    1. html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
    6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    7. <title>个人简历title>
    8. head>
    9. <body>
    10. <h1>李华的简历h1>
    11. <h2>基本信息h2>
    12. <img src="https://i01piccdn.sogoucdn.com/17e322ad5c5e7c50" width = "180px" height = "180px" alt="照片">
    13. <p>应聘岗位:Java 开发工程师p>
    14. <p>联系电话:13955546745p>
    15. <p>邮箱:3167723456@qq.comp>
    16. <div>
    17. <a href="https://gitee.com/xiaobite_hl">我的 Giteea>
    18. div>
    19. <div>
    20. <a href="https://i.csdn.net/#/user-center/profile?spm=1011.2266.3001.5111">我的博客a>
    21. div>
    22. <h2>教育背景h2>
    23. <ol>
    24. <li>2002-2008 培正幼儿园li>
    25. <li>2008-2014 培正小学li>
    26. <li>2014-2017 培正中学li>
    27. <li>2017-2020 培正高中li>
    28. <li>2020-2022 培正大学li>
    29. ol>
    30. <h2>专业技能h2>
    31. <ul>
    32. <li>熟练掌握 Java 的基本语法,熟悉面向对象程序设计;li>
    33. <li>熟悉常用的数据结构,例如:顺序表、链表、栈、队列、二叉树、哈希表等等;li>
    34. <li>熟练掌握 MySQL 数据库,可以使用 SQL 语句完成基本的增删改查;li>
    35. <li>熟悉进程和线程的基本概念,熟练掌握多线程编程,理解线程安全的相关问题和解决方案;li>
    36. <li>熟悉网络原理和网络编程,尤其是对于 TCP/IP/HTTP 等重要的协议有所理解。li>
    37. ul>
    38. <h2>项目经历h2>
    39. <ol>
    40. <li>
    41. <h3>留言墙h3>
    42. <p>开发时间:2022 年 8 月 9 日 ~ 2022 年 9 月 9 日p>
    43. <p>功能介绍:p>
    44. <ul>
    45. <li>支持留言发布li>
    46. <li>支持匿名留言li>
    47. ul>
    48. li>
    49. <h3>学习小助手h3>
    50. <p>开发时间:2022 年 6 月 10 日 ~ 2022 年 8 月 10 日p>
    51. <p>功能介绍:p>
    52. <ul>
    53. <li>支持错题检索li>
    54. <li>支持同学讨论li>
    55. ul>
    56. <li>
    57. li>
    58. ol>
    59. <h2>个人评价h2>
    60. <p>在校期间,学习努力认真,吃苦耐劳!p>
    61. body>
    62. html>

    效果图: 

    2.2 填写简历信息

    1. html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
    6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    7. <title>填写简历信息title>
    8. head>
    9. <body>
    10. <h1>请填写简历信息h1>
    11. <table width = "500px">
    12. <tr>
    13. <td>姓名td>
    14. <td>
    15. <input type="text">
    16. td>
    17. tr>
    18. <tr>
    19. <td>性别td>
    20. <td>
    21. <input type="radio" name="gender"> <img src="image/male.png" width="18px">
    22. <input type="radio" name = "gender"> <img src="image/female.png" width="18px">
    23. td>
    24. tr>
    25. <tr>
    26. <td>出生日期td>
    27. <td>
    28. <select>
    29. <option>--请选择年份--option>
    30. <option>1995option>
    31. <option>1996option>
    32. <option>1997option>
    33. <option>1998option>
    34. <option>1999option>
    35. <option>2000option>
    36. <option>2001option>
    37. <option>2002option>
    38. <option>2003option>
    39. <option>2004option>
    40. <option>2005option>
    41. <option>2006option>
    42. select>
    43. <select>
    44. <option>--请选择月份--option>
    45. <option>1option>
    46. <option>2option>
    47. <option>3option>
    48. <option>4option>
    49. <option>5option>
    50. <option>6option>
    51. <option>7option>
    52. <option>8option>
    53. <option>9option>
    54. <option>10option>
    55. <option>11option>
    56. <option>12option>
    57. select>
    58. <select>
    59. <option>--请选择日期--option>
    60. <option>1option>
    61. <option>2option>
    62. <option>3option>
    63. <option>4option>
    64. <option>5option>
    65. <option>6option>
    66. <option>7option>
    67. <option>8option>
    68. <option>9option>
    69. <option>10option>
    70. <option>11option>
    71. <option>12option>
    72. <option>13option>
    73. <option>14option>
    74. <option>15option>
    75. <option>16option>
    76. <option>17option>
    77. <option>18option>
    78. <option>19option>
    79. <option>20option>
    80. <option>21option>
    81. <option>22option>
    82. <option>23option>
    83. <option>24option>
    84. <option>25option>
    85. <option>26option>
    86. <option>27option>
    87. <option>28option>
    88. <option>29option>
    89. <option>30option>
    90. <option>31option>
    91. select>
    92. td>
    93. tr>
    94. <tr>
    95. <td>应聘岗位td>
    96. <td>
    97. <input type="checkbox"> 前端开发
    98. <input type="checkbox"> 后端开发
    99. <input type="checkbox"> 测试开发
    100. <input type="checkbox"> 运维开发
    101. td>
    102. tr>
    103. <tr>
    104. <td>掌握的技能td>
    105. <td>
    106. <textarea cols="30" rows="10">textarea>
    107. td>
    108. tr>
    109. <tr>
    110. <td>项目经历td>
    111. <td>
    112. <textarea cols="30" rows="10">textarea>
    113. td>
    114. tr>
    115. <tr>
    116. <td>td>
    117. <td>
    118. <input type="checkbox"> 我已阅读了公司的招聘要求
    119. td>
    120. tr>
    121. <tr>
    122. <td>td>
    123. <td>
    124. <a href="#">查看我的状态a>
    125. td>
    126. tr>
    127. <tr>
    128. <td>td>
    129. <td>
    130. <h3>请应聘者确认:h3>
    131. <ul>
    132. <li>以上信息真实有效li>
    133. <li>能够尽早去公司实习li>
    134. <li>能够接收公司的加班文化li>
    135. ul>
    136. td>
    137. tr>
    138. table>
    139. body>
    140. html>

    效果图:


    谢谢观看!!

  • 相关阅读:
    springboot增加license授权认证
    易基因|DNA-蛋白质互作的检测技术及ChIP-seq实验关键 | 易讲堂
    前端架构-分层而治,铁打的MV流水的C
    【C语言_线程pthread_互斥锁mutex_条件触发cond 之解析与示例 (开源)】.md updata:23/11/03
    JavaWeb三大组件-Filter
    29.5.4 恢复数据
    百度地图数据可视化
    win11下安装golang
    第14届蓝桥杯省赛 ---- C/C++ C组
    基于单片机体温脉搏检测控制系统及源程序
  • 原文地址:https://blog.csdn.net/xaiobit_hl/article/details/126802562