1. HTMLIntroduction
HTML (HyperText Markup Language) is 构建网页 标准标记language. 它using标记tag来describes网页 structure and in 容. HTML不 is aprogramminglanguage, 而 is a标记language, 用于定义网页 structure.
1.1 HTML 发展history
- HTML 1.0: 1993年release, is HTML 第一个version
- HTML 2.0: 1995年release, 成 for 互联网标准
- HTML 3.2: 1997年release, 增加了表格, frameworketc.元素
- HTML 4.01: 1999年release, 增加了样式表support
- HTML5: 2014年release, 增加了许how newfeatures, such as语义化tag, Canvas, 视频etc.
2. HTMLdocumentationstructure
2.1 basicstructure
一个basic HTMLdocumentationstructureincluding以 under 部分:
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>页面标题</title>
</head>
<body>
<!-- 页面 in 容 -->
<h1>欢迎来 to 我 网站</h1>
<p>这 is a HTMLexample页面. </p>
</body>
</html>
2.2 documentationstructure说明
<!DOCTYPE html>: documentationclass型声明, 告诉浏览器这 is a HTML5documentation<html>: 根元素, package含整个HTMLdocumentation<head>: 头部, package含documentation 元data, such as标题, 字符集etc.<body>: 主体, package含页面 可见 in 容
3. HTMLtag
3.1 tag basic语法
HTMLtag通常成 for 出现, including开始tag and 结束tag:
<标signature> in 容</标signature>
has 些tag is 自闭合 , 不需要结束tag:
<标signature property="值" />
3.2 常用tag
<h1> to <h6>: 标题tag, h1最 big , h6最 small<p>: 段落tag<a>: 链接tag<img>: graph像tag<div>: 块级containerstag<span>: in 联containerstag
4. HTMLproperty
4.1 property basic语法
HTMLproperty用于providing关于HTML元素 额 out information, 通常 in 开始tagin指定:
<标signature property1="值1" property2="值2"> in 容</标signature>
4.2 常用property
id: 元素 唯一标识符class: 元素 class名, 用于CSS样式style: in 联样式href: 链接 目标地址 (用于atag)src: resource path (用于img, scriptetc.tag)alt: graph像 替代文本 (用于imgtag)
5. HTMLcomment
HTMLcomment用于 in codein添加comment, 不会 in 浏览器in显示:
<!-- 这 is a HTMLcomment -->
<p>这 is a 段落</p>
实践case: creation一个 simple HTML页面
creation一个 simple HTML页面, package含以 under in 容:
- 页面标题 for "我 第一个HTML页面"
- 页面package含一个一级标题"欢迎来 to 我 网站"
- 页面package含一个段落, 介绍你自己
- 页面package含一个链接, 指向百度首页
- 页面package含一个graph像 (可以usingnetwork on graph像URL)
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>我 第一个HTML页面</title>
</head>
<body>
<h1>欢迎来 to 我 网站</h1>
<p> big 家 good , 我 is 一名WebDevelopment爱 good 者, 正 in LearningHTML. </p>
<a href="https://www.baidu.com" target="_blank">访问百度</a>
<img src="https://picsum.photos/200/300" alt="examplegraph像">
</body>
</html>
6. HTMLdocumentationclass型 and 字符集
6.1 documentationclass型声明
documentationclass型声明 (DOCTYPE) 告诉浏览器using哪个HTMLversion来解析页面:
<!DOCTYPE html>
6.2 字符集
字符集声明告诉浏览器using哪种字符编码来解析页面, 推荐usingUTF-8:
<meta charset="UTF-8">
互动练习: creation一个个人Introduction页面
1. creation一个HTML页面, package含以 under in 容:
- 页面标题 for "个人Introduction"
- 页面package含一个一级标题"关于我"
- 页面package含至 few 三个段落, 介绍你 basicinformation, 兴趣爱 good and 技能
- 页面package含一个链接, 指向你喜欢 网站
- 页面package含一个graph像, 展示你 照片 or 喜欢 graph片
2. verification你 HTMLcode is 否正确:
- 确保所 has tag都正确闭合
- 确保documentationclass型声明 and 字符集声明都正确
- 确保页面 in 浏览器in显示正常
7. HTMLwriting规范
7.1 code风格
- using small 写tag and property名
- using双引号package围property值
- indentcode以improving readable 性
- usingcomment说明 complex code
7.2 best practices
- using语义化tag
- optimizationgraph像 big small and 格式
- using out 部CSS and JavaScript
- 确保页面可访问性
- test页面 in 不同浏览器in 显示效果