Skip to content

Commit

Permalink
docs(html): <meta> element must be contained in <head> element
Browse files Browse the repository at this point in the history
  • Loading branch information
guoyunhe committed Jan 4, 2025
1 parent 9be6e8d commit dc1aea4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/coding/html.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ If a part of the document is written in another language, add `lang` attribute t
### 3.1. `mandatory` `<meta>` element must be contained in `<head>` element

```html
<!-- ❌ meta in body -->
<!--<meta> in <body> -->
<!doctype html>
<html lang="zh-CN">
<head>
Expand Down
28 changes: 27 additions & 1 deletion docs/coding/html.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ order: 1
</html>
```

### 2.3. `mandatory` `<html>` 元素的内容必须有且仅有一个 `<head>` 和一个 `<body>`
### 2.3. `强制` `<html>` 元素的内容必须有且仅有一个 `<head>` 和一个 `<body>`

```html
<!-- ❌ 缺少 <head> -->
Expand Down Expand Up @@ -171,6 +171,32 @@ order: 1

## 3. `<meta>` 元素

### 3.1. `强制` `<meta>` 元素必须包含在 `<head>` 元素内

```html
<!-- ❌ <meta> 在 <body> 里 -->
<!doctype html>
<html lang="zh-CN">
<head>
...
</head>
<body>
<meta charset="utf-8" />
</body>
</html>

<!-- ✅ 正确 -->
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
</head>
<body>
...
</body>
</html>
```

- 1.3.1 `推荐` 使用 UTF-8 字符编码。

声明一个明确的字符编码,可以让浏览器更快速高效地确定适合网页内容的渲染方式。
Expand Down

0 comments on commit dc1aea4

Please sign in to comment.