HTML elements are nested. Certain elements can only happen within other elements: that is, between particular opening and closing tags. The order in which tags are opened and closed is vitally important, since using them in the wrong sequence results in a page rendered in disarray in a browser.
HTML元素是嵌套的 。 某些元素只能在其他元素内发生:即在特定的开始和结束标签之间。 标签的打开和关闭顺序至关重要,因为按错误的顺序使用它们会导致页面在浏览器中混乱显示。
Tags are closed in the reverse order to which they are opened. The rule is: “First in, last out”. That is, the element that contains a nested series of tags is the last one to be closed. Another way of thinking about this is a series of matryoshka dolls, the Russian figurines which contain other figures inside themselves.
标签以与打开相反的顺序关闭。 规则是:“先进先出”。 也就是说,包含嵌套标签系列的元素是最后一个要关闭的元素。 对此的另一种思考方式是一系列俄罗斯套娃,其中包含其他人物。
If the <html>
tag starts our page after the doctype, it is also the last one to be closed:
如果<html>
标签在doctype之后开始我们的页面,则它也是最后一个要关闭的页面:
<html>
…
</html>
![HTML tattoo](https://i-blog.csdnimg.cn/blog_migrate/4215dc5e943fa01b5112c0094d998f89.png)
(Note that for the purposes of simple illustration the html
tag is simplified: in a real page, it would typically have at least a lang
attribute.)
(请注意,出于简单说明的目的,简化了html
标签:在实际页面中,它通常至少具有lang
属性 。)
Essentially, the <html>
tag indicates that everything that follows it is, unsurprisingly, HTML. The opening <html>
tag says “HTML starts here”. The closing </html>
tag says “this is where the HTML code ends”.
本质上, <html>
标记表示紧随其后的所有内容都是HTML。 开头的<html>
标记显示“ HTML从此处开始”。 结束符</html>
标记为“这是HTML代码的结尾”。
The rest of our code must be written between these opening and closing tags. There are two major sub-sections: the <head>
and <body>
.
我们其余的代码必须写在这些开始和结束标记之间。 有两个主要的子部分: <head>
和<body>
。
<html>
<head>
…
</head>
<body>
…
</body>
</html>
The <body>
section contains the content that will appear on our page. The <head>
section contains information about the page, together with other resources.
<body>
部分包含将出现在我们页面上的内容 。 <head>
部分包含有关页面的信息以及其他资源。