Blogger Information
Blog 14
fans 0
comment 1
visits 12860
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
0403 html 基础知识 2
王珂
Original
548 people have browsed it

0403 html 基础知识 2

1.语义化结构元素

  • <h1>-<h6>:划分段落
  • <header>:页眉
  • <footer>:页脚
  • <main>:主体
  • <aside>:边栏
  • <section>:区块
  • <nav>:导航
  • <div>:通用容器

    1.1 非语义化结构

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8" />
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    6. <title>传统方式:非语义化结构</title>
    7. </head>
    8. <body>
    9. <!---页眉-->
    10. <div class="header">
    11. <div class="nav">
    12. <a href="">Menu1</a>
    13. <a href="">Menu2</a>
    14. <a href="">Menu3</a>
    15. </div>
    16. </div>
    17. <!---内容主体区-->
    18. <div class="container">
    19. <!---边栏-->
    20. <div class="aside">
    21. <div class="ads">广告位</div>
    22. </div>
    23. <!---主体区-->
    24. <div class="main">
    25. <div class="article">
    26. <h3>php中文网</h3>
    27. <p>WEB开发者的家园</p>
    28. </div>
    29. </div>
    30. </div>
    31. <!---页脚-->
    32. <div class="footer">
    33. <div class="links">
    34. <a href="">links1</a>
    35. <a href="">links2</a>
    36. <a href="">links3</a>
    37. </div>
    38. </div>
    39. </body>
    40. </html>

    1.2语义化结构

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>语义化结构</title>
  7. </head>
  8. <body>
  9. <!---页眉-->
  10. <header>
  11. <nav>
  12. <a href="">Menu1</a>
  13. <a href="">Menu2</a>
  14. <a href="">Menu3</a>
  15. </nav>
  16. </header>
  17. <!---内容主体区-->
  18. <div class="container">
  19. <!---边栏-->
  20. <aside>
  21. <section class="ads">广告位</section>
  22. </aside>
  23. <!---主体区-->
  24. <main>
  25. <article>
  26. <header></header>
  27. <h3>php中文网</h3>
  28. <p>WEB开发者的家园</p>
  29. <footer></footer>
  30. </article>
  31. </main>
  32. </div>
  33. <!---页脚-->
  34. <footer>
  35. <section class="links">
  36. <a href="">links1</a>
  37. <a href="">links2</a>
  38. <a href="">links3</a>
  39. </section>
  40. </footer>
  41. </body>
  42. </html>

2.语义化的文本元素

  • <p>:段落,<pre>:代码原样渲染,<br>:换行,<span>:通用内联元素
  • <time>:时间,<abbr>:缩写,<address>:地址,<code>:代码段

    2.1

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8" />
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    6. <title>语义化的文本元素</title>
    7. </head>
    8. <body>
    9. <time>2020-04-03 </time>
    10. <p>
    11. <abbr title="超文本标记语言">HTML</abbr>
    12. </p>
    13. <p>2<sup>4</sup>=16</p>
    14. <footer>
    15. <address>合肥市政务新区</address>
    16. </footer>
    17. <p>
    18. <code>
    19. const username = 'admin'
    20. </code>
    21. </p>
    22. </body>
    23. </html>

    3.链接,列表与图象

  • <a>:链接

  • <ul><li>无序列表</li></ul>
  • <ol><li>有序列表</li></ol>
  • <img>:图像

    3.1链接

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8" />
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    6. <title>链接元素</title>
    7. </head>
    8. <body>
    9. <a href="https://www.php.cn" target="_blank">PHP中文网</a>
    10. <a href="https://www.php.cn">PHP中文网</a>
    11. <a href="0403.zip" download="html教程.md.zip">html教程0403</a>
    12. <a href="tel:1571111111">咨询热线</a>
    13. <a href="mailto:123@qq.com">联系我们</a>
    14. <a href="#author1">跳转到锚点1</a>
    15. <a href="#author2">跳转到锚点2</a>
    16. <h1 id="author1" style="margin-top:1000px;">我是锚点1</h1>
    17. <h1 id="author2" style="margin-top:2000px;">我是锚点2</h1>
    18. </body>
    19. </html>

    3.1列表

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8" />
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    6. <title>列表元素</title>
    7. </head>
    8. <body>
    9. <!---无序列表-->
    10. <ul>
    11. <li>苹果5斤</li>
    12. <li>梨3斤</li>
    13. <li>葡萄9斤</li>
    14. </ul>
    15. <hr />
    16. <!---有序列表-->
    17. <ol start="5">
    18. <li>苹果5斤</li>
    19. <li>梨3斤</li>
    20. <li>葡萄9斤</li>
    21. </ol>
    22. <hr />
    23. <!---自定义列表-->
    24. <dl>
    25. <dt>HTML</dt>
    26. <dd>超文本标记语言</dd>
    27. <dd>是一种标识性的语言</dd>
    28. <dt>css</dt>
    29. <dd>层叠样式表</dd>
    30. <dt>PHP</dt>
    31. <dd>超文本预处理器</dd>
    32. <dt>MYSQL</dt>
    33. <dd>数据库</dd>
    34. </dl>
    35. </body>
    36. </html>

4.表格与框架

  • <table> + <tr> + <td>

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8" />
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    6. <title>表格元素</title>
    7. </head>
    8. <body>
    9. <table
    10. border="1"
    11. cellpadding="5"
    12. cellspacing="0"
    13. width="500"
    14. height="200"
    15. align="center"
    16. >
    17. <colgroup bgcolor="lightpink">
    18. <col />
    19. <col bgcolor="lightgreen" />
    20. <col bgcolor="yellow" span="2" />
    21. <col />
    22. <col />
    23. </colgroup>
    24. <caption style="font-size:1.5rem;margin-bottom:10px;">
    25. 员工信息表
    26. </caption>
    27. <thead bgcolor="lightblue">
    28. <tr>
    29. <th>部门</th>
    30. <th>ID</th>
    31. <th>姓名</th>
    32. <th>职务</th>
    33. <th>手机</th>
    34. </tr>
    35. </thead>
    36. <tbody>
    37. <tr>
    38. <td rowspan="3" align="center">开发部</td>
    39. <td>101</td>
    40. <td>小王</td>
    41. <td>主管</td>
    42. <td>13313313313</td>
    43. </tr>
    44. <tr>
    45. <td>102</td>
    46. <td>小王</td>
    47. <td>主管</td>
    48. <td>13313313313</td>
    49. </tr>
    50. <tr>
    51. <td>103</td>
    52. <td>小王</td>
    53. <td>主管</td>
    54. <td>13313313313</td>
    55. </tr>
    56. <tr>
    57. <td rowspan="2" align="center">销售部</td>
    58. <td>103</td>
    59. <td>小王</td>
    60. <td>主管</td>
    61. <td>13313313313</td>
    62. </tr>
    63. <tr>
    64. <td>103</td>
    65. <td>小王</td>
    66. <td>主管</td>
    67. <td>13313313313</td>
    68. </tr>
    69. </tbody>
    70. <tfoot bgcolor="wheat">
    71. <td>备注</td>
    72. <td colspan="4">所有员工离职必须提交申请</td>
    73. </tfoot>
    74. </table>
    75. </body>
    76. </html>

5.表单元素

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>表单元素1</title>
  7. </head>
  8. <body>
  9. <h3>用户注册</h3>
  10. <form action="">
  11. <section>
  12. <label for="username">用户名:</label>
  13. <input
  14. type="text"
  15. id="username"
  16. name="username"
  17. maxlength="20"
  18. placeholder="不少于8位"
  19. required
  20. autofocus
  21. />
  22. </section>
  23. <section>
  24. <label for="password">密码:</label>
  25. <input
  26. type="password"
  27. id="password"
  28. name="password"
  29. placeholder="不少于8位"
  30. required
  31. size="10"
  32. />
  33. </section>
  34. <section>
  35. <label for="secret">性别:</label>
  36. <div class="box">
  37. <input type="radio" name="gender" id="male" value="male" />
  38. <label for="male"></label>
  39. <input type="radio" name="gender" id="female" value="female" />
  40. <label for="female"></label>
  41. <input
  42. type="radio"
  43. name="gender"
  44. id="secret"
  45. value="secret"
  46. checked
  47. />
  48. <label for="secret">保密</label>
  49. </div>
  50. </section>
  51. <section>
  52. <label for="shoot">兴趣:</label>
  53. <div class="box">
  54. <input
  55. type="checkbox"
  56. name="hobby[]"
  57. id="game"
  58. value="game"
  59. checked
  60. />
  61. <label for="">游戏</label>
  62. <input type="checkbox" name="hobby[]" id="travel" value="travel" />
  63. <label for="">旅游</label>
  64. <input type="checkbox" name="hobby[]" id="shoot" value="shoot" />
  65. <label for="">摄影</label>
  66. </div>
  67. </section>
  68. </form>
  69. </body>
  70. </html>
Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:挺好, 有个图更好
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!