html详解

html详解

1. 什么是HTMl?

  • Hyper Text Markup Language(超文本标记语言)
    • 超文本:图片,音频,视频…..

1.1 HTML的基本结构

1.2 网页框架标签

  1. DOCTYPE:告诉浏览器,我们要使用什么规范
  2. html: 网页都囊括在html标签中
  3. head:网页的头部
  4. body:代表网页的主体
  5. title:网页的标题
  6. meta:描述网站的一些信息(一般用来做SEO)

1.3 网页的基本标签

  1. 标题标签
1
2
3
4
5
6
<!--标题标签-->
<h1>一级标签</h1>
<h2>二级标签</h2>
<h3>三级标签</h3>
<h4>四级标签</h4>
<h5>五级标签</h5>

效果如下:

  1. 段落标签
1
2
3
<!--段落标签-->
<p>两只老虎 两只老虎</p>
<p>跑的快 跑的快</p>

效果如下:

  1. 换行标签
1
2
3
<!--换行标签-->
两只老虎 两只老虎<br/>
跑的快 跑的快<br/>

效果如下:

  1. 水平线标签
1
2
<!--水平线标签-->
<hr/>

效果图下:

  1. 字体样式标签
1
2
3
<!--字体样式标签-->
粗体:<strong>This is 粗体</strong>
斜体:<em>This is 斜体</em>

效果如下:

  1. 特殊符号
1
2
3
4
5
6
7
<!--特殊符号-->
&nbsp;

&gt; 大于号
&lt; 小于号

&copy; 版权符号
  1. 图像标签

1
<img src="../resources/image/证件照.jpg" alt="我的证件照" title="帅照" width="300" height="300">
  1. 链接标签

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<!--
herf: 必填,表示要跳转到哪个页面
target:表示窗口在哪里打开
target="_blank":在新的窗口打开
target="_self":在当前页面打开
-->

<a href="Basictags.html" target="_blank">点击我跳转的页面一</a>
<a href="www.baidu.com" target="_self">点击我跳转到百度</a>

<br>

<a href="Basictags.html">
<img src="../resources/image/证件照.jpg" alt="我的证件照" title="帅照" width="300" height="300">
</a>

7.1 锚链接

1
2
3
4
5
<a name="top"></a>
<!--锚链接
1.需要一个锚标记
2.跳转到标记(用#号)-->
<a href="#top">点击我回到顶部</a>

7.2 功能性链接

  1. QQ链接:https://shang.qq.com/v3/index.html

1
<a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=&site=qq&menu=yes"><img border="0" src="http://wpa.qq.com/pa?p=2::51" alt="朱酱酱的QQ" title="朱酱酱的QQ"/></a>
  1. 邮件链接
1
2
3
4
5
<!--功能性链接
邮件链接:mailto
-->

<a href="mailto:353446503@qq.com">点击联系我</a>
  1. 列表标签

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!--有序列表
应用范围:需要顺序的-->
<ol>
<li>Java</li>
<li>Python</li>
<li>运维</li>
<li>前端</li>
<li>C/C++</li>
<li>PHP</li>
</ol>


<!--无序列表
应用范围:侧边栏,导航-->
<ul>
<li>Java</li>
<li>Python</li>
<li>运维</li>
<li>前端</li>
<li>C/C++</li>
<li>PHP</li>
</ul>


<!--自定义标签
dl:标签
dt:列表名称
dd:列表内容-->
<dl>
<dt>学科</dt>
<dd>Java</dd>
<dd>运维</dd>
<dd>前端</dd>
<dd>C/C++</dd>
<dd>PHP</dd>

<dt>位置</dt>
<dd>江苏</dd>
<dd>南京</dd>
<dd>上海</dd>

</dl>

效果如下:

  1. 表格标签

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<!--表格table
行 tr
列 td
border : 加边框
-->
<table border="1px">
<tr>
<!--colspan跨列-->
<td colspan="4"></td>
</tr>
<tr>
<!--rowspan跨行-->
<td rowspan="2"></td>
</tr>
<tr>
<td>3-1</td>
<td>3-2</td>
<td>3-3</td>
</tr>
</table>

效果如下:

1.4 行内元素和块元素

1.5 媒体元素

视频和音频

1
2
3
4
5
6
7
8
9
10
<!--video
src:资源目录
controls:控制条
autoplay:自动播放-->
<video src="../resources/video/XXX.mp4" controls autoplay></video>

<!--audio
controls:控制条
autoplay:自动播放-->
<audio src="../resources/audio/XXX.mp3" controls autoplay></audio>

2. 页面结构分析

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<body>

<header>
<h2>网页头部</h2>
</header>

<section>
<h2>网页主题</h2>
</section>

<footer>
<h2>网页脚部</h2>
</footer>

</body>

3.iframe内联框架

B 站举例:

1
<iframe src="//player.bilibili.com/player.html?aid=55631961&cid=97257967&page=11" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"> </iframe>

博客举例:

1
2
3
4
5
6
7
<!--iframe内联框架
src:地址
w-h:宽度高度-->

<iframe src="" name="hello" frameborder="0" width="1600" height="900"></iframe>

<a href="http://zhuuu.work" target="hello">点击跳转</a>

4. 表单

4.1 表单语法

4.2 实现简单登录

实现简单登录:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<body>

<h1>注册</h1>
<!--表单form
action:表单提交的位置,可以是网站,也可以是一个请求处理地址
method:post,get提交方式
get:可以在url中看到我们提交的信息,不安全,搞笑
post:在url中看不到提交的信息,安全但不高效,可以传输大的文件
-->

<form action="Basictags.html" method="get">
<!--文本输入框-->
<p>名字: <input type="text" name="username"></p>
<p>密码: <input type="password" name="password"></p>

<p>
<input type="submit">
<input type="reset">
</p>
</form>


</body>

4.3 表单元素格式

  1. 单选框
1
2
3
4
5
6
7
8
<!--单选框
input type = "radio"
value: 单选框的值
name: 表示一个组,name一样就是同一个组-->
<p>性别:
<input type="radio" value="boy" name="gender">男孩
<input type="radio" value="girl" name="gender">女孩
</p>
  1. 多选框
1
2
3
4
5
6
7
8
9
<!--多选框
input type="checkbox"-->
<p>爱好:
<input type="checkbox" value="睡觉" name="hobbys">睡觉
<input type="checkbox" value="代码" name="hobbys">代码
<input type="checkbox" value="聊天" name="hobbys">聊天
<input type="checkbox" value="看片" name="hobbys">看片
<input type="checkbox" value="游戏" name="hobbys">游戏
</p>
  1. 按钮
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<!--自定义按钮
input type="button" :普通按钮
input type="image" :图像按钮
input type="submit" :提交按钮
input type="reset" :重置按钮
-->
<p>按钮:
<input type="button" name="btn1" value="点击变长">
<input type="image" src="../resources/image/证件照.jpg">
</p>


<!--提交按钮-->
<p>
<input type="submit">
<input type="reset" value="清空表单">
</p>

</form>
  1. 列表框下拉框
1
2
3
4
5
6
7
8
9
10
<!--下拉框
selected:设定默认值-->
<p>下拉框:
<select name="列表名称" >
<option value="选项的值">中国</option>
<option value="选项的值">美国</option>
<option value="选项的值" selected>日本</option>
<option value="选项的值">韩国</option>
</select>
</p>
  1. 文本域
1
2
3
4
5
<!--文本域
-->
<p>反馈:
<textarea name="textarea" cols="30" rows="10"></textarea>
</p>
  1. 文件域
1
2
3
4
5
<!--文件域:上传文件-->
<p>
<input type="file" name="files">
<input type="button" value="上传" name="upload">
</p>
  1. label标签

作用:增强鼠标的可用性

1
2
3
4
5
6
<!--label
点击文字会让搜索框生效-->
<p>
<label for="mark">你点我试试</label>
<input type="text" id="mark">
</p>

4.4 表单的应用

  1. 只读(readonly)
1
<p>名字: <input type="text" name="username" value="admin" readonly></p>
  1. 禁用(disabled)
1
2
3
4
<p>性别:
<input type="radio" value="boy" name="gender" disabled>男孩
<input type="radio" value="girl" name="gender">女孩
</p>
  1. 隐藏(hidden)
1
<p>密码: <input type="password" name="password" hidden></p>

4.5 表单初级验证

  1. placeholder(提示信息)
1
<p>名字: <input type="text" name="username" placeholder="请输入用户名"></p>
  1. required (非空判断)
1
<p>密码: <input type="password" name="password" required></p>
  1. pattern(正则表达式判断 )
1
2
3
4
5
<!--正则表达式判断
pattern-->
<p>
<input type="text" name="diymail" pattern="^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$">
</p>

这里的正则表达式用来验证邮箱:

1
^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$

5. 简单验证

5.1 邮箱验证

1
2
3
4
<!--邮件验证-->
<p>邮箱:
<input type="email" name="email">
</p>

5.2 url验证

1
2
3
4
<!--url验证-->
<p>
<input type="url" name="url">
</p>

5.3 数字验证

1
2
3
4
<!--数字验证-->
<p>
<input type="number" name="num" max="100" min="0" step="10">
</p>

5.4 滑块验证

1
2
3
4
5
<!--滑块验证
-->
<p>滑块:
<input type="range" name="voice" min="0" max="100">
</p>

通常可用于音量调节

5.5 搜索框

1
2
3
4
5
<!--搜索框
-->
<p>
<input type="search" name="search">
</p>

6. HTML总结

name代表提交的键值对中的键

name一定不能少

以下自己总结的iframe内联式思维导图

打赏
  • 版权声明: 本博客所有文章除特别声明外,均采用 Apache License 2.0 许可协议。转载请注明出处!
  • © 2019-2022 Zhuuu
  • PV: UV:

请我喝杯咖啡吧~

支付宝
微信