HTML5
什么是HTML
html(Hyper Text Markup Language)超文本标记语言
超文本包括:文字,图片,音频,视频,动画,等
HTML5,提供了一些新的元素和一些有趣的新特性,同时也建立了一些新的规则。这些元素、特性和规则的建立,提供了许多新的网页功能,如使用网页实现动态渲染图形、图表、图像和动画,以及不需要安装任何插件直接使用网页播放视频等。
HTML5的优势
- 世界知名浏览器厂商对HTML5的支持
- 微软
- 苹果
- Opera
- Mozilla
- 市场的需求
- 跨平台
W3C标准
- W3C
- World Wide Web Consortium (万维网联盟)
- 成立于1994年,Web技术领域最权威和具影响力的国际中立性技术标准机构
- http://www.w3.org/
- http://www.chinaw3c.org/
- W3C标准包括
- 结构化标准语言(HTML.XML)
- 表现标准语言(CSS)
- 行为标准(DOM、ECMAScript )
HTML基本结构
<html>
<head>
<title>我的第一个网页</title> ------->网页头部
</head>
<body>
我的第一个网页 ---------->主体部分
</body>
</html>
< body>、 等成对的标签,分别叫开放标签和闭合标签
单独呈现的标签(空元素),如<hr/>
; 意为用/
来关闭空元素
网页基本信息
- DOCTYPE声明
<title>标签
<meta>标签
网页基本标签
-
标题标签
<h1>
-
段落标签
<p1>
-
换行标签
</br>
-
水平线标签
<hr>
-
字体样式标签
粗体:<strong></strong> 斜体:<em></em>
-
注释和特殊符号
<!--注释-->
空格
©版权所有
<!-- DOCTYPE:告诉浏览器,我们要使用什么规范 -->
<!DOCTYPE html>
<html lang="en">
<!--head标签代表网页头部-->
<head>
<!--meta描述标签,它用来描述我们网站的一些信息-->
<!--meta一般用来做SEO-->
<meta charset="UTF-8">
<meta name="keywords" content="xzzs0507">
<meta name="viewport" content="width=device-width, initial">
<!--title网页标题-->
<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>
<h4>四级标签</h4>
<h5>五级标签</h5>
<h6>六级标签</h6>
<!--段落标签-->
<p>The following</p>
<p>is the same as the following.</p>
<p>The following is the same as the following.</p>
<!--换行标签-->
</br>
<!--水平线标签-->
<hr>
<!--粗体和斜体-->
<h1>字体样式标签</h1>
粗体:<strong>i love you</strong>
</br>
斜体:<em>i love you</em>
</br>
<!--特殊符号-->
空格:
空 格
</br>
>
</br>
<
©版权所有
<!--特殊符号记忆方式
& ;
-->
</body>
</html>
图像标签
-
常见的图像格式
- JPG
- GIF
<img src="path" alt="text" title="text" width="x" height="y" />
src:图像地址
alt:图像的替代文字
title:鼠标悬停提示文字
width:图像宽度
height:图像高度
- PNG
- BMP
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>图像标签学习</title> </head> <body> <!--img学习 src:图片地址 相对地址,绝对地址 ../ ---上一级目录 alt : 图片名字(必填) --> <img src="..\resurces\image\小黄人.jpg"alt="小黄人"title = "悬停文字:小黄人"width="300"height="300"> <img src="..\resurces\image\二次1元.png"alt="二次元壁纸"title = "悬停文字:二次元壁纸"> <a href="4.链接标签.html#down">跳转</a> </body> </html>
链接标签
<a href = "path" target = "目标窗口位置">链接文本或图像</a>
href: 链接路径
target: 链接在哪个窗口打开
目标窗口位置常用值:_self
、_blank
- 文本超链接
- 图像超链接
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>链接标签学习</title>
</head>
<body>
<!--使用name作为标记-->
<a name="top">顶部</a>
<!--a标签
href:必填,表示要跳转到那个页面
target:表示窗口在哪里打开
_blank:在新标签中打开
_self:在自己的网页中打开
-->
<a href="1.第一个网页.html"target="_blank">点击我跳转到页面一</a>
<a href="http://www.baidu.com"target="_self">点击我跳转到百度</a>
<br>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
<!--
<p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p>
<p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p>
<p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p>
<p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p>
<p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p><p>
<a href="1.第一个网页.html">
<img src="../resurces/image/小黄人.jpg" alt="小黄人" title="小黄人悬停文字"width="300"height="300">
</a>
</p>
-->
<!--锚链接
1.需要一个锚标记
2.跳转到标记
#
-->
<a href="#top">回到顶部</a>
<a name = "down">down</a>
<!--功能性链接
邮件链接:mailto:
-->
<a href="mailto:3328779021@qq.com" target="_blank">点击联系我</a>
</body>
</html>
超链接
- 页面间链接
- 从一个页面链接到另一个页面
- 锚链接
- 功能性链接
行内元素和块元素
- 块元素
- 无论内容多少,该元素独占一行
- (p、h1-h6…)
- 行内元素
- 内容撑开宽度,左右都是行内元素的可以在排在一行
- (a.strong.em…)
列表标签
- 什么是列表
- 列表就是信息资源的一种展示形式。它可以使信息结构化和条理化,并以列表的样式显示出来,以便浏览者能更快捷地获得相应的信息
- 列表的分类
- 无序列表
- 有序列表
- 定义列表
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>列表学习</title>
</head>
<body>
<!--有序列表-->
<ol>
<li>Java</li>
<li>Python</li>
<li>运维</li>
<li>前端</li>
<li>C/C++</li>
</ol>
<!--无序列表
应用范围:导航,侧边栏...
-->
<ul>
<li>Java</li>
<li>Python</li>
<li>运维</li>
<li>前端</li>
<li>C/C++</li>
</ul>
<!--自定义列表
dl:标签
dt:列表名称
dd:列表内容
公司网站底部
-->
<dl>
<dt>学科</dt>
<dd>Java</dd>
<dd>Python</dd>
<dd>Linux</dd>
<dd>C</dd>
<dt>位置</dt>
<dd>四川</dd>
<dd>重庆</dd>
<dd>贵州</dd>
<dd>云南</dd>
</dl>
</body>
</html>
表格标签
- 为什么使用表格
- 简单通用
- 结构稳定
- 基本结构
- 单元格
- 行
- 列
- 跨行
- 跨列
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>表格学习</title>
</head>
<body>
<!--表格table
行 tr
列 td
-->
<table border="1px">
<tr>
<!-- colspan 跨列-->
<td colspan="4">1-1</td>
<!-- <td>1-2</td>-->
<!-- <td>1-3</td>-->
<!-- <td>1-4</td>-->
</tr>
<tr>
<!-- rowspan 跨行-->
<td rowspan="2">2-1</td>
<td>2-2</td>
<td>2-3</td>
<td>2-4</td>
</tr>
<tr>
<!-- <td>3-1</td>-->
<td>3-2</td>
<td>3-3</td>
<td>3-4</td>
</tr>
<tr>
<td>4-1</td>
<td>4-2</td>
<td>4-3</td>
<td>4-4</td>
</tr>
</table>
</body>
</html>
媒体元素
- 视频元素
- video
- 音频元素
- audio
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>媒体元素学习</title>
</head>
<body>
<!--音频和视频
src:资源路径
controls:控制条
autoplay:自动播放
-->
<video src="../resurces/video/视频.mp4" width="100%" height="100%" controls autoplay></video>
<audio src="../resurces/audio/你打我撒.mp3" controls autoplay></audio>
</body>
</html>
页面结构分析
元素名 | 描 述 |
---|---|
header | 标题头部区域的内容(用于页面或页面中的一块区域) |
footer | 标记脚部区域的内容(用于整个页面或页面的一块区域) |
section | Web页面中的一块独立区域 |
article | 独立的文章内容 |
aside | 相关内容或应用(常用于侧边栏) |
nav | 导航类辅助内容 |
iframe内联框架
<iframe src="path" name="mainFrame" ></iframe>
path:引用页面地址
mainFrame:框架标识名
表单语法
method:规定如何发送表单数据 ---- 常用值:get l post
action:表示向何处发送表单数据
<form method="pdst" action="result.html">
<p> 名字: <input name="name" type="text" > </p>
<p> 密码: <input name="pass" type="password" > </p>
<p>
<input type="submit" name="Button" value="提交"1>
<input type="reset" name="Reset" value="重填**/>
</p>
</form>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>表单学习:登录注册</title>
</head>
<body>
<h1>注册</h1>
<!--表单form
action : 表单提交的位置,可以是网站,也可以是一个请求处理地址
method : post ,get 提交方法
get 方式提交:我们可以在url中看到我们提交的信息,不安全但高效
post方式提交比较安全,可以传输大文件,
-->
<!--<form action="1.第一个网页.html" method="get">
<!–文本输入框:input type = "text"–>
<p>名字:<input type="text" name="username"></p>
<!–密码框:imput type = "password"–>
<p>密码:<input type="password" name="pwd"></p>
<p>
<input type="submit">
<input type="reset">
</p>
</form>-->
<form action="1.第一个网页.html" method="post">
<!--文本输入框:input type = "text"-->
<p>名字:<input type="text" name="username"></p>
<!--密码框:imput type = "password"-->
<p>密码:<input type="password" name="pwd"></p>
<p>
<input type="submit">
<input type="reset">
</p>
</form>
</body>
</html>
表单元素格式
属性 | 说明 |
---|---|
type | 指定元素的类型。text、password、checkbox、radio、submit、reset、file、hidden、image 和 button,默认为 text |
name | 指定表单元素的名称 |
value | 元素的初始值。type 为 radio时必须指定一个值 |
size | 指定表单元素的初始宽度。当type 为 text 或 password时,表单元素的大小以字符为单位。对于其他类型,宽度以像素为单位 |
maxlength | type为text 或 password 时,输入的最大字符数 |
checked | type为radio或checkbox时,指定按钮是否是被选中 |
表单的应用
- 隐藏域 hidden
- 只读 readonly
- 禁用 disabled
表单初级验证
- 思考?为什么要进行表单验证
- 常用方式
- placeholder 提示信息
- required 非空判断
- pattern 正则表达式(正则表达式速查表_)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>表单学习:登录注册</title>
</head>
<body>
<h1>注册</h1>
<!--表单form
action : 表单提交的位置,可以是网站,也可以是一个请求处理地址
method : post ,get 提交方法
get 方式提交:我们可以在url中看到我们提交的信息,不安全但高效
post方式提交比较安全,可以传输大文件
value:默认初始值
maxlength:最长能写几个字符
size:文本框长度
-->
<!--<form action="1.第一个网页.html" method="get">
<!–文本输入框:input type = "text"–>
<p>名字:<input type="text" name="username"></p>
<!–密码框:imput type = "password"–>
<p>密码:<input type="password" name="pwd"></p>
<p>
<input type="submit">
<input type="reset">
</p>
</form>-->
<form action="1.第一个网页.html" method="get">
<!--文本偷入瓶 :input type="text"
value="狂神好帅"" 默认初始值
maxlength="8" 最长能写儿个字符
size="3o" 文本框的长度
-->
<!--文本输入框:input type = "text"-->
<p>名字:<input type="text" name="username" placeholder="请输入用户名:" maxlength="30" size="20" required></p><!--value="默认名称" readonly-->
<!--密码框:imput type = "password"-->
<p>密码:<input type="password" name="pwd" hidden required></p>
<!--单选框标签
input: type = "radio"
value:单选框的值
name:表示组
-->
<p>性别:
<input type="radio" value="boy" name="sex" checked disabled/>男
<input type="radio" value="girl" name="sex"/>女
</p>
<!--多选框
input type="checkbox"
-->
<p>爱好:
<input type="checkbox" value="sleep" name="hobby">睡觉
<input type="checkbox" value="code" name="hobby" checked>敲代码
<input type="checkbox" value="game" name="hobby">玩游戏
<input type="checkbox" value="chat" name="hobby">聊天
</p>
<!--按钮
input type="button" 普通按钮
input type="image" 图像按钮
input type="submit" 提交按钮
input type="reset" 重置按钮
-->
<p>按钮:
<input type="button" name="btn1" value="点击确认">
<!-- <input type="image"src="../resurces/image/小黄人.jpg">-->
</p>
<!--下拉框,列表框
-->
<p>国家:
<select name="列表名称">
<option value="American">美国</option>
<option value="japanese">日本</option>
<option value="china" selected>中国</option>
<option value="Germany">德国</option>
<option value="U.K">英国</option>
</select>
</p>
<!--文本域
cols="50" rows="10"
-->
<p>反馈:
<textarea name="textarea" cols="50" rows="10">文本内容</textarea>
</p>
<!--文件域
input type="file" name = "files"aaaaaaaaa
-->
<p>
<input type="file" name="files">
<input type="button" value="上传" name="upload">
</p>
<!--邮件验证-->
<p>邮箱:
<input type="email" name="email"required>
</p>
<!--URL -->
<p>URL:
<input type="url" name="url"required>
</p>
<!--数字-->
<p>商品数量:
<input type="number" name="num" max="100" min="0" step="1"required>
</p>
<!--滑块
input type="range"
-->
<p>音量:
<input type="range" name="voice" max="100" min="0" step="2">
</p>
<!--搜索框-->
<p>搜索:
<input type="search" name="search">
</p>
<p>
<!--增强鼠标可用性-->
<label for="mark">点我</label>
<input type="text"id="mark">
</p>
<!--https://www.w3cschool.cn/yfmth7/yfmth7-ex2n28a2.html-->
<p>自定义邮箱:
<input type="text"name="diymail"pattern="/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/
/^[a-z\d]+(\.[a-z\d]+)*@([\da-z](-[\da-z])?)+(\.{1,2}[a-z]+)+$/">
</p>
<p>
<input type="submit" value="提交表单" ><!--disabled-->
<input type="reset" value="清空表单">
</p>
</form>
</body>
</html>