学习要点:
1.HTML5 文档结构
2.文档结构解析
3.元素标签探讨
主讲教师:李炎恢
本章主要先从 HTML5 的文档结构谈起。 这些基础元素确定了 HTML 文档的轮廓以及浏览器的初始环境。几乎所有页面都必须首先键入这些元素。
一.HTML5 文档结构
1.第一步:打开 Sublime Text 3,打开指定文件夹;
2.第二步:保存 index.html 文件到磁盘中,.html 是网页后缀;
3.第三步:开始编写 HTML5 的基本格式。
<!DOCTYPE html> //文档类型声明<html lang="zh-cn"> //表示 HTML 文档开始 <head> //包含文档元数据开始 <meta charset="utf-8"> //声明字符编码 <title>基本结构</title> //设置文档标题 </head> //包含文档元数据结束 <body> //表示 HTML 文档内容 <a href="http://www.baidu.com">百度</a> //一个超链接元素(标签) </body> //表示 HTML</html> //表示 HTML 文档结束
二.文档结构解析
1.Doctype
文档类型声明(Document Type Declaration,也称 Doctype)。它主要告诉浏览器所查看的文件类型。 在以往的 HTML4.01 和XHTML1.0 中, 它表示具体的 HTML 版本和风格。而如今 HTML5 不需要表示版本和风格了。
<!DOCTYPE html> //不分区大小写
2.html 元素
首先,元素就是标签的意思,html 元素即 html 标签。html 元素是文档开始和结尾的元素。它是一个双标签,头尾呼应,包含内容。这个元素有一个属性和值:lang="zh-cn",表示文档采用语言为:简体中文。
<html lang="zh-cn"> //如果是英文则为 en
3.head 元素
用来包含元数据内容,元数据包括:、、
<head>...</head> //这些信息在页面不可见
4.meta 元素
这个元素用来提供关于文档的信息,起始结构有一个属性为:charset="utf8"。表示告诉浏览器页面采用的什么编码,一般来说我们就用 utf8。当然,文件保存的时候也是utf8,而浏览器也设置 utf8 即可正确显示中文。
<meta charset="utf-8"> //除了设置编码,还有别的
5.title 元素
这个元素很简单,顾名思义:设置浏览器左上角的标题。
<title>基本结构</title>
6.body 元素
用来包含文档内容的元素,也就是浏览器可见区域部分。所有的可见内容,都应该在这个元素内部进行添加。
<body>...</body>
7.a 元素
一个超链接,后面会详细探讨。
<a href="http://www.baidu.com">百度</a>
三.元素标签探讨
HTML 是一种标记语言,刚才的结构我们已经详细探讨过。这里,我们再剖析一下这些“标记”或者叫“标签”,书面上经常称作为“元素”的东西是怎么构成的。
1.元素
元素就是一组告诉浏览器如何处理一些内容的标签。每个元素都有一个关键字,比如
元素一般分为两种:单标签(空元素)和双标签。单标签一般用于声明或者插入某个元素,比如声明字符编码就用,插入图片就用
...
。2.属性和值
元素除了有单双之分, 元素的内部还可以设置属性和值。 这些属性值用来改变元素某些方面的行为。比如超链接:中的href 属性,里面替换网址即可链接到不同的网站。当然一个元素里面可以设置多个属性,甚至自定义属性。

The official account web page update cache, this thing is simple and simple, and it is complicated enough to drink a pot of it. You worked hard to update the official account article, but the user still opened the old version. Who can bear the taste? In this article, let’s take a look at the twists and turns behind this and how to solve this problem gracefully. After reading it, you can easily deal with various caching problems, allowing your users to always experience the freshest content. Let’s talk about the basics first. To put it bluntly, in order to improve access speed, the browser or server stores some static resources (such as pictures, CSS, JS) or page content. Next time you access it, you can directly retrieve it from the cache without having to download it again, and it is naturally fast. But this thing is also a double-edged sword. The new version is online,

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

This article demonstrates efficient PNG border addition to webpages using CSS. It argues that CSS offers superior performance compared to JavaScript or libraries, detailing how to adjust border width, style, and color for subtle or prominent effect

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

This article explains the HTML5 <time> element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Mac version
God-level code editing software (SublimeText3)

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
