一、什么是HTML?
Hyper Text Markup Language(超文本标记语言)
超文本包括:文字,图片,音频,视频,动画等。
世界知名浏览器厂商都对HTML5支持:微软,谷歌,苹果,Opera,Mozilla。
W3C World Wide Web Consortium(万维网联盟) Web技术领域最权威和具有影响力的国际中立性技术标准机构
W3C标准包括:
结构化标准语言(HTML XML)
表现标准语言(CSS)
行为标准(DOM ECMAScript)
HTML的基本结构
![](https://img-blog.csdnimg.cn/img_convert/4a6993b9f30ab9c3c422fd2e2e548a95.png)
开放标签和自闭和标签是成对出现的
(1)注释 <!-- **** --!> Ctrl + /
(2)DOCTYPE 告诉浏览器使用什么规范
<!--告诉浏览器使用的规范-->
<!DOCTYPE html>
<html lang="en">
<!-- head标签代表网页头部-->
<head>
<!-- meta 描述性标签,用来描述网站的一些信息 -->
<meta charset="UTF-8">
<meta name = "keywords" content="java">
<meta name="description" content="study">
<!-- title表示网页标题 -->
<title>我的首创</title>
</head>
<!-- body标签代表网页主题 -->
<body>
hello world!
</body>
</html>
网页基本标签
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>基本标签学习</title>
</head>
<body>
<!--标题标签-->
<h1>一级标签</h1>
<h2>二级标签</h2>
<h3>三级标签</h3>
<!--段落标签-->
<p>12</p>
<p>123</p>
<p>1234</p>
<!--水平线标签-->
<hr/>
<!--换行标签-->
12<br/>
1234<br/>
12345<br/>
<!--字体样式标签-->
粗体:<strong>Java</strong>
斜体:<em>Java</em>
<br/>
<!--特殊符号-->
空格
空 格
<br/>
大于号:>
<br/>
小于号:<
<br/>
©版权所有
</body>
</html>
效果如下图所示:
![](https://img-blog.csdnimg.cn/img_convert/fb9fba0823a44f1fa1e992f6f53cdb19.png)
图像标签 img
![](https://img-blog.csdnimg.cn/img_convert/a2af78cb6b87169fe891a8bc4c6f8211.png)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>图像标签学习</title>
</head>
<body>
<img src="../resources/image/1.jpg" alt="小猪猪" title="壁纸" width="500" height="300">
</body>
</html>
![](https://img-blog.csdnimg.cn/img_convert/8c0e2a0702ecb0d29e3aadf61f7d228f.png)
链接标签 a
![](https://img-blog.csdnimg.cn/img_convert/9ca7ba862fdb8a668da6ba991fdb138f.png)
target:表示窗口在哪里打开
_blank:在新标签页中打开
_self:在自己的网页下打开
4.1 页面间链接
<body>
<!--文字连接-->
<a href="1.我的第一个网页.html" target="_blank">点击跳转</a>
<a href="https://www.baidu.cpm">点击跳转到百度</a>
<br/>
<!--图片链接-->
<a href="1.我的第一个网页.html">
<img src="../resources/image/1.jpg" alt="小猪猪" title="壁纸" width="500" height="3000">
</a>
</body>
4.2 锚链接
使用锚链接可以将页面跳转到指定的位置
![](https://img-blog.csdnimg.cn/img_convert/ed09438af062be242dbf349fac613d91.png)
支持跨页面跳转
<a href="4.链接标签.html">跳转</a>
4.3 功能性链接
邮件链接
<a href="mailto:[email protected]">点击联系我</a>
![](https://img-blog.csdnimg.cn/img_convert/10e837c663c031720e1b213049723ad8.png)
行内元素和块元素
块元素
无论内容多少,该元素独占一行
行内元素
内容撑开宽度,左右都是行内元素的可以排在一行
二、列表和表格
列表标签 list
什么是列表?
信息资源的一种展示形式。它可以使信息结构化和条理化,并以列表的样式显示出来,以便浏览者能够更快捷地获得相应的信息。
分类:无序列表 有序列表 定义列表
<body>
<!--有序列表-->
<ol>
<li>Java</li>
<li>Python</li>
<li>运维</li>
<li>前端</li>
<li>C</li>
</ol>
<hr>
<!--无序列表-->
<ul>
<li>java</li>
<li>python</li>
<li>c</li>
<li>c++</li>
</ul>
<hr>
<!--自定义列表
dl:标签
dt:列表名称
dd:列表内容
-->
<dl>
<dt>学科</dt>
<dd>java</dd>
<dd>python</dd>
<dd>c</dd>
</dl>
</body>
![](https://img-blog.csdnimg.cn/img_convert/f50b977c1718a32803ff06d7b5be3ce6.png)
表格标签 table
属性:
border 边框大小
colspan 跨列
rowspan 跨行
实现如图所示的表格
![](https://img-blog.csdnimg.cn/img_convert/e07a91eea5f6fac26e4fa6813fcf5968.png)
<body>
<!--表格 table
行 tr rows
列 td
-->
<!--border 边框间距-->
<table border="1px">
<tr>
<!--colspan 跨列-->
<!--rowspan 跨行-->
<td colspan="2">姓名:</td>
<td colspan="2">性别:</td>
<td rowspan="4">照片</td>
</tr>
<tr>
<td colspan="2">身高:</td>
<td colspan="2">体重:</td>
</tr>
<tr>
<td colspan="2">出生年月:</td>
<td colspan="2">民族:</td>
</tr>
<tr>
<td>电子邮件:</td>
</tr>
</table>
</body>
![](https://img-blog.csdnimg.cn/img_convert/4c9f220d750136fbdad4c99fa8a67fa2.png)
三、媒体元素(视频元素 video 和 音频元素 audio)
属性:
src 资源路径
controls 进度条控制
autoplay 自动播放
<body>
<!--视频
src 资源路径
controls 进度条控制
autoplay 自动播放
-->
<video src="../resources/video/f062e7d901bbe8f1107dea4e904a3cc2.mp4"controls autoplay></video>
<!--音频-->
<audio src="../resources/audio/nvhaier.mp3" controls autoplay></audio>
</body>
![](https://img-blog.csdnimg.cn/img_convert/8642ac07862864203dbad769c0a8e03b.png)
四、 页面结构分析
![](https://img-blog.csdnimg.cn/img_convert/2a79689746d9dbcdec0d72503e502414.png)
五、内联框架 iframe
![](https://img-blog.csdnimg.cn/img_convert/1d7a232c6acd6c3cfb24856e6c737caf.png)
<body>
<iframe src="" name="hello" frameborder="0" width="1000px" height="800px"></iframe>
<a href="https://www.bilibili.com" target="hello">点击跳转</a>
<!--或者
<iframe src="https://www.bilibili.com" frameborder="0" width="1000px" height="800px"></iframe>
-->
</body>
六、 表单语法 form
初识表单get和post提交
![](https://img-blog.csdnimg.cn/img_convert/36fe9861efc41b2b6f930f8b4b7e3221.png)
action:表单提交的位置,可以是网站,也可以是一个请求处理地址
method: post, get提交方式
get方式提交可以在URL中看到提交的信息 不安全,但高效,不能传输大文件
post方式提交不显示,比较安全,可以传输大文件
<body>
<h1>注册</h1>
<!--表单form-->
<form action="1.我的第一个网页.html" method="get">
<!--文本输入框-->
<p>名字:<input type="text" name="username"> </p>
<p>密码:<input type="password" name="pwd"> </p>
<!--submit提交 reset重置-->
<p>
<input type="submit">
<input type="reset">
</p>
</form>
</body>
![](https://img-blog.csdnimg.cn/img_convert/9640b5104e06a18b6d70893f94767649.png)
表单格式
![](https://img-blog.csdnimg.cn/img_convert/a853f80c9684995beff1951ddc72210b.png)
单选框 radio
![](https://img-blog.csdnimg.cn/img_convert/e08781b8bfc1f4472bc6bf88de04a75f.png)
单选框标签
input type="radio"
value:单选框的值
name:表示组,组名一样表示在同一个组中
<!-- checked 表示默认选中-->
<p>性别:
<input type="radio" value="boy" name="sex" checked>男
<input type="radio" value="girl" name="sex">女
</p>
多选框 checkbox
![](https://img-blog.csdnimg.cn/img_convert/a4f011d966cf208c6711d746af0c0bad.png)
多选按钮也要放在同一个组里。
<!-- checked 表示默认选中-->
<p>爱好:
<input type="checkbox" value="sleep" name="hobby" checked>睡觉
<input type="checkbox" value="code" name="hobby" checked>代码
<input type="checkbox" value="chat" name="hobby">聊天
<input type="checkbox" value="play" name="hobby">玩耍
</p>
按钮 button
普通按钮 图片按钮 提交按钮 重置按钮
![](https://img-blog.csdnimg.cn/img_convert/82b76651233d67fe555673a94e5358fd.png)
![](https://img-blog.csdnimg.cn/img_convert/d012f9f98da217268e20fbb896646859.png)
<p>按钮:
<input type="button" name="btn1" value="基本按钮">
<input type="image" src="../resources/image/1.jpg" value="图片按钮">
</p>
<!--submit提交 reset重置-->
<p>
<input type="submit">
<input type="reset">
</p>
下拉框 select
![](https://img-blog.csdnimg.cn/img_convert/8d2d7a6a63bf3721a24a7b843ef2531b.png)
<!-- selected 表示默认选中-->
<p>国家:
<select name="列表名称">
<option value="china" >中国</option>
<option value="us"selected>美国</option>
<option value="ur">英国</option>
</select>
</p>
7. 文本域 textarea
![](https://img-blog.csdnimg.cn/img_convert/e22e53aa823abb7eb8d2a1683ca5fa7c.png)
<p>文本域:
<textarea name="textarea" cols="40" rows="10">文本内容</textarea>
</p>
8. 文件域 file
![](https://img-blog.csdnimg.cn/img_convert/05b6dac9a0e1f310b6baada21c168159.png)
<p>文件域:
<input type="file" name="files">
<input type="button" value="上传" name="upload">
</p>
9. 简单验证
当输入不符合规范,系统就会自动提示。
![](https://img-blog.csdnimg.cn/img_convert/2a4144c81bc7a4e0494a8d4b80af41fd.png)
![](https://img-blog.csdnimg.cn/img_convert/9e33e2f711c14d135764975ce203674f.png)
<p>邮箱:
<input type="email" name="email">
</p>
<p>url:
<input type="url" name="url">
</p>
<p>数字
<input type="number" name="num" min="0" max="100" step="10">
</p>
10. 滑块 range
![](https://img-blog.csdnimg.cn/img_convert/c0a7d362359ae381b968f2a79fcff111.png)
<p>音量:
<input type="range" name="voice" min="0" max="100" step="2">
</p>
11. 搜索框 search
![](https://img-blog.csdnimg.cn/img_convert/890829aa017410dca335968d30a7036a.png)
<p>搜索:
<input type="search" name="search">
</p>
七、表单的应用
只读 readonly
只能看,不能重写,修改
![](https://img-blog.csdnimg.cn/img_convert/d687a0c19b2a1305651371e7c660c9ad.png)
<p>名字:<input type="text" name="username" value="admin" readonly> </p>
禁用 disabled
选项变灰色,不能自己选择
![](https://img-blog.csdnimg.cn/img_convert/d05ab2b892733bcfc6fe688510ab5a5f.png)
<p>性别:
<input type="radio" value="boy" name="sex" checked disabled>男
<input type="radio" value="girl" name="sex">女
</p>
隐藏域 hidden
输入框隐藏,但属性还在
![](https://img-blog.csdnimg.cn/img_convert/f68c3549a38f193d18aed9e23e774fe1.png)
<p>密码:<input type="password" name="pwd" hidden> </p>
通过隐藏域可以提交默认值
4. 附加
<p>
<!-- 增强鼠标可用性:点击文本框前文字鼠标可以锁定到文本框中-->
<label for="mark">点击</label>
<input type="text" id="mark">
</p>
八、表单的初级验证
提示信息 placeholder
应用在输入框的控件中
![](https://img-blog.csdnimg.cn/img_convert/b5cb21059408a21e728c28072c09b3be.png)
<p>名字:<input type="text" name="username" placeholder="请输入用户名"></p>
2. 非空判断 required
应用在输入框的控件中
![](https://img-blog.csdnimg.cn/img_convert/bd33add0fc5e874769245813a425bb73.png)
<p>密码:<input type="password" name="pwd" required> </p>
3. 正则表达式 pattern
正则表达式查找网站:
https://www.jb51.net/tools/regex.htm
<p>自定义邮箱:
<input type="text" name="diymail" pattern="^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$">
</p>
===========================================================
内容繁多,重在理解!
感谢ლ(°◕‵ƹ′◕ლ)!!!