</pre><p><span style="font-family:Microsoft YaHei;">(吐槽一下,CSDN博客的文本编译器真是。。。唉。。。)</span></p><p><div style="orphans: auto; widows: auto;"><span style="color:#231f20;"></span><p style="font-family: SimSun;"><span style="font-size:14px;">一个网页主要包含三个部分:</span></p><p style="font-family: SimSun;"><span style="font-size:14px;"><span style="white-space: pre;"> </span>文本内容 text content</span></p><p style="font-family: SimSun;"><span style="font-size:14px;"><span style="white-space: pre;"> </span>对其他文件的引用 references to other files</span></p><p style="font-family: SimSun;"><span style="font-size:14px;"><span style="white-space: pre;"> </span>标记 markup</span></p><p style="font-family: SimSun;"><span style="font-size:14px;"></span></p><p><span style="font-size:14px;"><span style="font-family:SimSun;">开始</span><span style="font-family: SimSun; white-space: pre;"> </span></span></p><p><span style="font-family:SimSun;font-size:14px;"><span style="white-space:pre"></span></span></p><p><span style="font-family: SimSun;"><span style="white-space:pre"> </span>开始标签(如 <head>)用于标记元素的开始</span></p><p><span style="color: rgb(35, 31, 32);"><span style="font-family: SimSun;"><span style="white-space:pre"> </span>结束标签(如 </head>)用于标记元素的结束。</span></span></p><p><span style="color: rgb(35, 31, 32);"><span style="font-family: SimSun;"><span style="white-space:pre"> </span>有的元素没有结束标签, 如 meta。</span></span></p><p><span style="color: rgb(35, 31, 32);"><span style="font-family: SimSun;"></span></span></p></div></p><p><span style="font-family:SimSun;font-size:14px;"><span style="white-space: pre;"> </span>把多个空格和制表符压缩成单个空格</span></p><p><span style="white-space:pre"><span style="font-family:SimSun;font-size:14px;"> <span style="color: rgb(35, 31, 32); white-space: pre;"><strong><!DOCTYPE html></strong>:</span><span style="color: rgb(35, 31, 32);">用DOCTYPE 声 明 开 始HTML 文档, 让浏览器知道这是一个HTML5 页面。</span></span></span></p><p><span style="font-family:SimSun;font-size:14px;"><span style="white-space: pre;"> </span>字符<strong style="background-color: rgb(255, 255, 255);"><meta charset="utf-8"></strong></span></p><p><span style="white-space: pre;"><span style="font-family:SimSun;font-size:14px;"><span style="color: rgb(35, 31, 32);"><span style="white-space:pre"> </span>页面内容都在body元素中。<strong>主要<span style="background-color: rgb(255, 255, 204);">为浏览器和搜索引擎准备的指令</span>位于body元素之前,在head元素中。</strong><br style="orphans: 2; text-align: -webkit-auto; widows: 2;" /></span></span></span></p><span style="font-family:SimSun;font-size:14px;"></span><span style="font-family:SimSun;font-size:14px;"></span><p><pre name="code" class="html"><span style="font-family:SimSun;font-size:14px;"><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Your page title</title>
</head>
<body>
</body>
</html></span>
标记:
元素 element
属性 attribute
值 value
元素:
元素<em>amazed</em>
空元素:不包含任何文本内容,如img
属性和值:
多个属性-值用空格隔开
有的属性只接受特定值【预定义值、枚举值】,如link-all/screen/print
数字值不需要输入单位
文件名规则:
文件名全部使用小写字母,用短横线分隔单词,用 .html 作为扩展名。
如果页面使用其他的扩展名(如.txt),浏览器会将其当做文本处理。
URL:
URL(Uniform Resource Locator,统一资源定位符)是地址的别名。
它包含关于文件存储位置和浏览器应如何处理它的信息。
互联网上的每个文件都有唯一的URL。
【注意】URL路径不以文件名结尾,而以一个目录结尾(可以包含一个结尾的斜杠,也可以不包含)。
在这种情况下,URL 指的是路径中最后一个目录中的默认文件,通常为index.html。
(通常情况下,所有 Web 服务器的配置都将 index.html 作为默认文件名,因此你不必修改任何服务器配置。)
模式 scheme:
HTTP|HTTPS(安全网页):Hypertext TransferProtocol,超文本传输协议
FTP:File Transfer Protocol,文件传输协议
绝对URL|相对URL(根相对 URL:先跳到网站的根目录再顺着向下找到目标文件)
语义化HTML(semantic HTML):那些使用最恰当的 HTML 元素进行标记的内容,在标记的过程中并不关心内容显示。
提升搜索引擎优化(SEO)的效果
浏览器对网页的默认显示效果:
每个 Web 浏览器都有一个内置 CSS 文件(一张样式表),它决定了每个HTML 元素的默认样式。
HTML 并不负责表现。CSS 控制 HTML 内容的表现。