嵌套HTML元素

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

(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>部分包含有关页面的信息以及其他资源。

翻译自: https://thenewcode.com/8/Nesting-HTML-Elements

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值