HTML
HTML简单介绍
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<!--超链接-->
<a href="https://www.bilibili.com/">bilibili</a>
</body>
</html>
- 注释
注释为代码的阅读者提供帮助,不参与运行
格式如下:
<!--注释内容-->
可以换行写多行
-
元素 标签 标记
整体是一个element(元素)
<a href="https://www.bilibili.com/">bilibili</a>
元素 = 起始标记(begin tag) + 结束标记(end tag) + 元素内容 + 元素属性
属性 = 属性名 + 属性值
格式是:
<起始标记 属性名="属性值">元素内容</结束标记>
- 属性的分类
局部属性:某些元素特有的属性
全局属性: 所有的元素通用
注意:有些元素没有结束标记,这样的元素称为是空元素
例如:
<meta charset="UTF-8">
空元素的两种写法:
<meta charset="UTF-8">
<meta charset="UTF-8" />
- 元素的嵌套
元素之间是可以嵌套的,像body元素和head元素,但是不可以相互嵌套
由于元素之间是可以嵌套的,所以当一个元素中直接嵌套了另一个元素,前者可以称为是父元素,后者可以称为是子元素;当一个元素中包含另一个元素但是并没有直接嵌套时,前者可以称为是祖先元素,后者可以称为是后代元素,类似于html元素;当多个元素(至少两个以上)拥有同一个父元素,可以互相称为兄弟元素
例如:
<div>
<p></p>
</div>
- 标准的文档结构
<!--文档声明,告诉浏览器当前使用的是HTML标准是HTML5-->
<!DOCTYPE html>
<!--html根元素,一个页面最多只可以有一个,并且该元素是其他的元素的父元素或者是祖先元素,HTML5中没有强制要求书写该元素-->
<!--html元素中有一个属性是lang属性,代表的是language语言,是一个全局属性,表示该元素内部使用的文字是使用哪一种自然语言书写成的-->
<html lang="en">
<!--head元素作为html元素的子元素出现,表示文档头,文档头内部的内容不会显示到页面上-->
<head>
<!--meta元素代表的是文档的元数据,也就是附加信息,其中的charset属性告诉浏览器文字编码是UTF-8-->
<meta charset="UTF-8">
<!--适应手机端的-->
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<!--告诉浏览器使用的内核-->
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<!--title元素表示的是网页的标题-->
<title>这是我的第一个网页</title>
</head>
<!--body元素作为html元素的子元素出现,表示的是文档体,页面上所有要参与显示的元素,都应该放到文档体中-->
<body>
<!--超链接-->
<a href="https://www.bilibili.com/" title="网页">bilibili</a>
<h1 title="this is my first page">第一个网页</h1>
<img
src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAoHCBYVFRgVFhUYGBgaGBoZGhwYHBweHBwaHBgaGhgYGhgcIy4lHB4rIRgYJjgmKy8xNTU1GiQ7QDs0Py40NTEBDAwMEA8QHhISHzQrJSs0NDQ0NDY1NjQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NP/AABEIALcBEwMBIgACEQEDEQH/xAAbAAABBQEBAAAAAAAAAAAAAAACAAEDBAUGB//EAEIQAAEDAQQGBggFBAEDBQAAAAEAAhEDBBIhMUFRYXGBkQUTUqGx0QYiMkJiksHwFBZTouFygtLxFWPC4jNDRFSy/8QAGgEAAwEBAQEAAAAAAAAAAAAAAQIDAAQFBv/EAC0RAAIBAwIFBAEEAwEAAAAAAAABAgMREiFRBBMxQWEUUpGhsXGB8PEVItEF/9oADAMBAAIRAxEAPwDy28nvJrqV1a5rD3k4chhJC4bBylKGE6Fw2HJSlOEoWuHEaUiU8JXVrjKIMpXkd1K6tkHEEOT3k91K6hkMoivJSldT3FshlEaUiUV1K6tkNgDKUpyxK4tkbAa8lKe4nurZGwBJSvJXUrq2QrgNeTSnhMQjcVxFKa8mITEI3EaHL0JemhNCNxcQr6YuTQmWyNiOXpr6RTQjkCw99JDCSGQLFuE8Iw1EGKORTEiuJXFOGJwxbIbErXU9xWurTdWhkHArhicMVjq0gxbIZQIbiXVqyGIwxDMZQKoYiuK0KaXVoZDKBVuJurVwU0urQzGUCoGIurVoU0QpoOZSMCn1aQpq51SY0kvMGUCp1aXVq31SbqluYHllS6mLVaNJC5iKmBwKpCGFZLEDmJ1IRwK7ggIU7mIC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/AA4J9VxBGj+UkkWK9Ogf42qML2X3qSSSWsgZs//Z">
</body>
</html>
- 语义化
每一个HTML元素都有具体的含义
a元素:超链接
p元素:段落
h1元素:一级标题
所有的元素和展示效果无关
元素展示到页面中的效果,应该是由CSS决定的而不是由HTML决定的。
因为浏览器带有默认的CSS样式,所以每一个元素有一些默认样式
选择什么元素,取决于内容的含义,而不是显示出的效果
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1 style="font-size: .5em;font-weight: normal">这是一个一级标题</h1>
<p>这是一个段落</p>
</body>
</html>
为什么需要语义化?
为了搜索引擎优化:每隔一段时间,搜索引擎会从整个互联网中抓取页面源代码
为了让浏览器理解网页
HTML的文本元素
HTML5中支持的元素:HTML5的元素周期表
- h元素
h1到h6元素代表的是1级标题到六级标题,英文是head
- p元素
p元素代表段落
- span元素【无语义元素】
没有语义,仅用于设置样式
以前:某些元素在显示时会独占一行(块级元素),而某些元素不会(行级元素)
到了HTML5,已经弃用了这种说法
- pre元素
pre元素表示的是预格式化文本元素
空白折叠:在源代码中的连续空白字符(空格 换行 制表 ),在页面显示时,会被折叠成为一个空格
在pre元素中的内容不会出现空白折叠,会按照源代码的内容格式来显示在页面上
该元素通常用于在网页上显示一些代码
pre元素功能的本质:它是有一个默认的CSS的属性
- code元素
显示代码时,通常外面套code元素用来显示代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>一级标题</h1>
<h2>二级标题</h2>
<h3>三级标题</h3>
<h4>四级标题</h4>
<h5>五级标题</h5>
<h6>六级标题</h6>
<p>这是一个段落</p>
三原色包含:<span style="color: red">红</span>、<span style="color: green">绿</span>、<span style="color: blue">蓝</span>
<p>
₍₍◡( ╹◡╹ )◡₎₎
(ノ◕ω◕)ノ
(҂‾▵‾)︻デ═一
</p>
<pre>
₍₍◡( ╹◡╹ )◡₎₎
(ノ◕ω◕)ノ
(҂‾▵‾)︻デ═一
</pre>
<code>
<pre>
var i = 2;
if (i){
console.log(i);
}
</pre>
</code>
<code style="white-space: pre">
var i = 2;
if (i){
console.log(i);
}
</code>
</body>
</html>
-
HTML实体字符:
HTML Entity,实体字符通常用来在页面中显示一些特殊的符号
格式如下:
&单词;
&#数字;
常见的实体字符有:小于符号 大于符号 空格 版权符号 &符号
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
在页面中, 表示段落使用:<p>
©&
</body>
</html>