HTML5学习笔记

HTML (Hyper Text Mackup Language,超文本标记语言)

超文本包括文字、图片、音频、视频等。

在这里插入图片描述

W3C标准


在这里插入图片描述

HTML基本结构


在这里插入图片描述

<!-- <!DOCTYPE 告诉浏览器,这个文本要使用什么标准> -->
<!--  写DOCTYPE也可以,浏览器默认使用HTML标准 -->
<!DOCTYPE html>
<html lang="en">
<!-- 网页头部 -->
<head>
    <!-- <meta> -- 用于描述网站信息 -->
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 可以用于SEO -->
    <meta name="keywords" content="haha">
    <meta name="description" content="hoho">
    <title>Document</title>
</head>
<!-- 网页主体 -->
<body>
    
</body>
</html>

网页基本标签

标题标签

<h1>一级标签</h1>
<h2>二级标签</h2>
<h3>三级标签</h3>
<h4>四级标签</h4>
<h5>五级标签</h5>
<h6>六级标签</h6>

段落标签

<p>在该标签中段文字都属于这一自然段</p>

换行标签

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>网页基本标签</title>
</head>
<body>
    在该标签中段文字都属于这一自然段<br/>
</body>
</html>

水平线标签

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>网页基本标签</title>
</head>
<body>
    <hr/>
</body>
</html>

字体样式标签

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>网页基本标签</title>
</head>
<body>
    <p><strong>粗体</strong></p>
    <p><em>斜体</em></p>
    <p><i>Italy</i></p>
</body>
</html>

注释和特殊符号

<!-- 注释 -->
&nbsp;  空格 

更多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>超链接标签及应用</title>
</head>
<body>
    <!-- 在新页面打开链接 -->
    <a href="https://www.jiumodiary.com" target="_blank">Text</a>  
    <!-- 在本页打开链接 -->
    <a href="https://www.jiumodiary.com" target="_self">Text</a>

    <a href="https://www.jiumodiary.com" target="_blank">
        <img src="https://www2.jiumodiary.com/images/front/eleps.png" alt="缺省文字" title="悬停文字">
    </a>
</body>
</html>

锚链接

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>超链接标签及应用</title>
</head>
<body>
    <!-- 以id为锚点标记 -->
    <p> <a href="https://www.jiumodiary.com" target="_blank" id="top">Text</a>  </p>
    <p> <a href="https://www.jiumodiary.com" target="_self">Text</a> </p>
    <p>
        <a href="https://www.jiumodiary.com" target="_blank">
            <img src="https://www2.jiumodiary.com/images/front/eleps.png" alt="缺省文字" title="悬停文字">
        </a>
    </p>
    <p>
        <a href="https://www.jiumodiary.com" target="_blank">
            <img src="https://www2.jiumodiary.com/images/front/eleps.png" alt="缺省文字" title="悬停文字">
        </a>
    </p>
    <p>
        <a href="https://www.jiumodiary.com" target="_blank">
            <img src="https://www2.jiumodiary.com/images/front/eleps.png" alt="缺省文字" title="悬停文字">
        </a>
    </p>
    <p>
        <a href="https://www.jiumodiary.com" target="_blank">
            <img src="https://www2.jiumodiary.com/images/front/eleps.png" alt="缺省文字" title="悬停文字">
        </a>
    </p>
    <p>
        <a href="https://www.jiumodiary.com" target="_blank">
            <img src="https://www2.jiumodiary.com/images/front/eleps.png" alt="缺省文字" title="悬停文字">
        </a>
    </p>
    <p>
        <a href="https://www.jiumodiary.com" target="_blank">
            <img src="https://www2.jiumodiary.com/images/front/eleps.png" alt="缺省文字" title="悬停文字">
        </a>
    </p>
    <p>
        <a href="https://www.jiumodiary.com" target="_blank">
            <img src="https://www2.jiumodiary.com/images/front/eleps.png" alt="缺省文字" title="悬停文字">
        </a>
    </p>
    
    <p> <a href="#top">回到顶部</a> </p>

		<!-- 还可以实现任意页面任意锚点跳转 -->
    <p> <a href="https://www.jiumodiary.com/#top"></a> </p>
</body>
</html>

功能性链接

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <p>
        <a href="mailto:123@163.com"></a>
    </p>
</body>
</html> 

块内元素和行内元素


在这里插入图片描述

列表标签


无序列表

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <!-- unordered list -->
    <ul>
        <li>HTML5</li>
        <li>CSS3</li>
        <li>JavaScript</li>
    </ul>
</body>
</html>

有序列表

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <!-- ordered list -->
    <ol>
        <li>C++</li>
        <li>Golang</li>
        <li>Python</li>
    </ol>
</body>
</html>

自定义列表

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <!-- Defined List -->
    <dl>
        <!-- Defined Title -->
        <dt>Descipline</dt>
        <!-- Defined item -->
        <dd>Math</dd>
        <dd>English</dd>
        <dd>Chinese</dd>

        <dt>Week</dt>
        <dd>Monday</dd>
        <dd>Tuesday</dd>
    </dl>
</body>
</html>

表格标签


为什么要使用表格?

  • 简单通用
  • 结构稳定

基本结构:

  • 单元格
  • 跨行
  • 跨列
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <table border="1px">
        <!-- th: table header -->
        <th colspan="2px">A</th><th>B</th><th>C</th>
        <!-- tr: table row -->
        <tr>
            <!-- td: table data -->
            <td colspan="2px">1-1</td><td>1-2</td><td>1-3</td>
            <td>2-1</td><td>2-2</td><td>2-3</td>
        </tr>
        <tr>
            <!-- td: table data -->
            <td rowspan="2px">1-1</td><td>1-2</td><td>1-3</td>
            <td>2-1</td><td>2-2</td><td>2-3</td>
        </tr>
    </table>
</body>
</html>

媒体元素


Video

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <video src="a.mp4" controls="controls" autoplay="autoplay"></video>
</body>
</html>

Audio

<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>
    <audio src="a.mp3" controls="controls" autoplay="autoplay"></audio>
</body>
</html>

页面结构分析


在这里插入图片描述

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <header>
        <h2>Header</h2>
    </header>

    <nav>
        <h4>Navigation</h4>
    </nav>

    <section>
        <h1>Section1</h1>
    </section>

    <article>
        <h3>Article</h3>
    </article>

    <aside>
        <h3>Aside</h3>
    </aside>

    <footer>
        <h5>Footer</h5>
    </footer>
</body>
</html>

iframe内联框架


在这里插入图片描述

在一个网页内嵌套另一些网页

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <iframe name="jiumodiary" src="https://www.jiumodiary.com" frameborder="0" width="500px" height="500px">jiumodiary</iframe>

    <a href="https://www.bing.com" target="jiumodiary">在指定iframe中打开网页</a>
</body>
</html>

初识表单post和get提交


在这里插入图片描述

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <!-- <form action="url" method="POST | GET"> -->
    <!-- Get:可以直接在submit的url里看到提交到数据,不安全,但是高效 -->
    <!-- POST:在url里看不到提交到数据,但是也可以在inspect element里看到,可以后期加密 -->
    <form action="https://www.jiumodiary.com" method="POST">
        <p> UserName: <input type="text" name="username"> </p>
        <p> Password: <input type="password" name="password"> </p>
        <p> 
            <input type="submit"> 
            <input type="reset">
        </p>
    </form>
</body>
</html>

文本框和单选框


在这里插入图片描述

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <!-- <form action="url" method="POST | GET"> -->
    <!-- Get:可以直接在submit的url里看到提交到数据,不安全,但是高效 -->
    <!-- POST:在url里看不到提交到数据,但是也可以在inspect element里看到,可以后期加密 -->
    <form action="https://www.jiumodiary.com" method="GET">
        <p> UserName: <input type="text" name="username"> </p>
        <p> Password: <input type="password" name="password"> </p>
        <p> Gender: 
            Boy<input type="radio" value="boy" name="gender">
            Girl<input type="radio" value="girl" name="gender"> 
        </p>
        <p> 
            <input type="submit"> 
            <input type="reset">
        </p>
    </form>
</body>
</html>

按钮和多选框


<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <!-- <form action="url" method="POST | GET"> -->
    <!-- Get:可以直接在submit的url里看到提交到数据,不安全,但是高效 -->
    <!-- POST:在url里看不到提交到数据,但是也可以在inspect element里看到,可以后期加密 -->
    <form action="https://www.jiumodiary.com" method="GET">
        <p> UserName: <input type="text" name="username"> </p>
        <p> Password: <input type="password" name="password"> </p>
        <p> Gender: 
            Boy<input type="radio" value="boy" name="gender">
            Girl<input type="radio" value="girl" name="gender"> 
        </p>
        <p> Hobby:
            A<input type="checkbox" name="hobby" value="A">
            B<input type="checkbox" name="hobby" value="B">
            C<input type="checkbox" name="hobby" value="C">
        </p>
        <p>
            <input type="button" name="click" value="点击变长">
            <!-- 图片按钮 -->
            <input type="image" src="https://www2.jiumodiary.com/images/front/eleps.png">
        </p>
        <p> 
            <input type="submit"> 
            <input type="reset">
        </p>
    </form>
</body>
</html>

列表框、文本域和文件域


列表框、文本域和文件域

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <!-- <form action="url" method="POST | GET"> -->
    <!-- Get:可以直接在submit的url里看到提交到数据,不安全,但是高效 -->
    <!-- POST:在url里看不到提交到数据,但是也可以在inspect element里看到,可以后期加密 -->
    <form action="https://www.jiumodiary.com" method="GET">
        <p> UserName: <input type="text" name="username"> </p>
        <p> Password: <input type="password" name="password"> </p>
        <p> Gender: 
            Boy<input type="radio" value="boy" name="gender">
            Girl<input type="radio" value="girl" name="gender"> 
        </p>
        <p> 下拉框:
            <select name="options">
                <option value="1">1</option>
                <option value="2" selected>2</option>
                <option value="3">3</option>
            </select>
        </p>
        <p> 
            <input type="submit"> 
            <input type="reset">
        </p>
    </form>
</body>
</html>

文本域 Textarea

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <!-- <form action="url" method="POST | GET"> -->
    <!-- Get:可以直接在submit的url里看到提交到数据,不安全,但是高效 -->
    <!-- POST:在url里看不到提交到数据,但是也可以在inspect element里看到,可以后期加密 -->
    <form action="https://www.jiumodiary.com" method="GET">
        <p> UserName: <input type="text" name="username"> </p>
        <p> Password: <input type="password" name="password"> </p>
        <p> Gender: 
            Boy<input type="radio" value="boy" name="gender">
            Girl<input type="radio" value="girl" name="gender"> 
        </p>
        <p> 下拉框:
            <select name="options">
                <option value="1">1</option>
                <option value="2" selected>2</option>
                <option value="3">3</option>
            </select>
        </p>
        <p> 
            <input type="submit"> 
            <input type="reset">
        </p>
    </form>
</body>
</html>

搜索框滑块和简单验证


自带简单验证的组件

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <!-- <form action="url" method="POST | GET"> -->
    <!-- Get:可以直接在submit的url里看到提交到数据,不安全,但是高效 -->
    <!-- POST:在url里看不到提交到数据,但是也可以在inspect element里看到,可以后期加密 -->
    <form action="https://www.jiumodiary.com" method="GET">
        <p> UserName: <input type="text" name="username"> </p>
        <p> Password: <input type="password" name="password"> </p>
        <p> Gender: 
            Boy<input type="radio" value="boy" name="gender">
            Girl<input type="radio" value="girl" name="gender"> 
        </p>
        <p> Email checking: 
            <input type="email" name="email">
        </p>
        <p> URL checking: 
            <input type="url" name="url">
        </p>
        <p> Number checking: 
            <input type="number" name="number" max="100" min="0" step="10">
        </p>
        <p> 
            <input type="submit"> 
            <input type="reset">
        </p>
    </form>
</body>
</html>

滑块

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <!-- <form action="url" method="POST | GET"> -->
    <!-- Get:可以直接在submit的url里看到提交到数据,不安全,但是高效 -->
    <!-- POST:在url里看不到提交到数据,但是也可以在inspect element里看到,可以后期加密 -->
    <form action="https://www.jiumodiary.com" method="GET">
        <p> UserName: <input type="text" name="username"> </p>
        <p> Password: <input type="password" name="password"> </p>
        <p> Gender: 
            Boy<input type="radio" value="boy" name="gender">
            Girl<input type="radio" value="girl" name="gender"> 
        </p>
        <p> 滑块
            <input type="range" name="range" max="100" min="0">
        </p>
        <p> 
            <input type="submit"> 
            <input type="reset">
        </p>
    </form>
</body>
</html>

搜索框

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <!-- <form action="url" method="POST | GET"> -->
    <!-- Get:可以直接在submit的url里看到提交到数据,不安全,但是高效 -->
    <!-- POST:在url里看不到提交到数据,但是也可以在inspect element里看到,可以后期加密 -->
    <form action="https://www.jiumodiary.com" method="GET">
        <p> UserName: <input type="text" name="username"> </p>
        <p> Password: <input type="password" name="password"> </p>
        <p> Gender: 
            Boy<input type="radio" value="boy" name="gender">
            Girl<input type="radio" value="girl" name="gender"> 
        </p>
        <p> 搜索框
            <input type="search" name="search">
        </p>
        <p> 
            <input type="submit"> 
            <input type="reset">
        </p>
    </form>
</body>
</html>

表单的应用


  • 隐藏域
  • 只读
  • 禁用
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <!-- <form action="url" method="POST | GET"> -->
    <!-- Get:可以直接在submit的url里看到提交到数据,不安全,但是高效 -->
    <!-- POST:在url里看不到提交到数据,但是也可以在inspect element里看到,可以后期加密 -->
    <form action="https://www.jiumodiary.com" method="GET">
        <p> UserName: <input type="text" name="username" readonly> </p>
        <p> Password: <input type="password" name="password" hidden> </p>
        <p> Gender: 
            Boy<input type="radio" value="boy" name="gender" disabled>
            Girl<input type="radio" value="girl" name="gender"> 
        </p>
        <p> 
            <input type="submit"> 
            <input type="reset">
        </p>
    </form>
</body>
</html>

Label


<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <!-- <form action="url" method="POST | GET"> -->
    <!-- Get:可以直接在submit的url里看到提交到数据,不安全,但是高效 -->
    <!-- POST:在url里看不到提交到数据,但是也可以在inspect element里看到,可以后期加密 -->
    <form action="https://www.jiumodiary.com" method="GET">
        <p> UserName: <input type="text" name="username"> </p>
        <p> Password: <input type="password" name="password"> </p>
        <p> Gender: 
            Boy<input type="radio" value="boy" name="gender">
            Girl<input type="radio" value="girl" name="gender"> 
        </p>
        <p>
            <!-- 使用label可以增加鼠标的可用性,点文字如同点text框,即label所绑定的组件 -->
            <label for="text">Text</label>
            <input type="text" id="text">
        </p>
        <p> 
            <input type="submit"> 
            <input type="reset">
        </p>
    </form>
</body>
</html>

表单的初级验证


  • placeholder
  • required
  • pattern正则表达式
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <!-- <form action="url" method="POST | GET"> -->
    <!-- Get:可以直接在submit的url里看到提交到数据,不安全,但是高效 -->
    <!-- POST:在url里看不到提交到数据,但是也可以在inspect element里看到,可以后期加密 -->
    <form action="https://www.jiumodiary.com" method="GET">
        <p> UserName: <input type="text" name="username" placeholder="Please input user name"> </p>
        <p> Password: <input type="password" name="password" required> </p>
        <p> Gender: 
            Boy<input type="radio" value="boy" name="gender">
            Girl<input type="radio" value="girl" name="gender"> 
        </p>
        <p>
            <!-- 使用label可以增加鼠标的可用性,点文字如同点text框,即label所绑定的组件 -->
            <label for="text">Text</label>
            <input type="text" id="text" placeholder="Regex text checking" pattern="^\d">
        </p>
        <p> 
            <input type="submit"> 
            <input type="reset">
        </p>
    </form>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

PaddyH

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值