如何嵌套HTML元素

news/2024/7/7 15:05:45
How To Build a Website With HTML 如何使用HTML构建网站

This tutorial series will guide you through creating and further customizing this website using HTML, the standard markup language used to display documents in a web browser. No prior coding experience is necessary but we recommend you start at the beginning of the series if you wish to recreate the demonstration website.

本教程系列将指导您使用HTML(用于在Web浏览器中显示文档的标准标记语言)创建和进一步自定义此网站 。 不需要任何编码经验,但是如果您希望重新创建演示网站,建议您从本系列的开头开始 。

At the end of this series, you should have a website ready to deploy to the cloud and a basic familiarity with HTML. Knowing how to write HTML will provide a strong foundation for learning additional front-end web development skills, such as CSS and JavaScript.

在本系列的最后,您应该拥有一个可以部署到云的网站,并且对HTML有了基本的了解。 知道如何编写HTML将为学习其他前端Web开发技能(例如CSS和JavaScript)奠定坚实的基础。

This tutorial will teach you how to nest HTML elements in order to apply multiple HTML tags to a single piece of content.

本教程将教您如何嵌套HTML元素,以便将多个HTML标签应用于单个内容。

HTML elements can be nested, meaning that one element can be placed inside another element. Nesting allows you to apply multiple HTML tags to a single piece of content. For example, try pasting the following code snippet inside your index.html file:

HTML元素可以嵌套 ,这意味着一个元素可以放在另一个元素内。 嵌套允许您将多个HTML标签应用于单个内容。 例如,尝试将以下代码片段粘贴到index.html文件中:

<strong>My bold text and <em>my bold and emphasized text</em></strong>

Save your file and reload it in the browser. (For instructions on creating an index.html file, please see our tutorial here or for loading the file in your browser, see our tutorial here.) You should receive something like this:

保存文件,然后将其重新加载到浏览器中。 (有关创建index.html文件的说明,请参见此处的教程,或有关如何在浏览器中加载文件的信息,请参见此处的教程 。)您应该收到类似以下内容的信息:

My bold text and my bold and emphasized text

我的粗体字以及我的粗体和强调文本

嵌套最佳做法 (Nesting Best Practices)

Note that it is recommended to always close nested tags in the reverse order that they were opened. For example, in the example below, the <em> tag closes first as it was the last tag to open. The <strong> tag closes last as it was the first to open.

请注意,建议始终以与打开嵌套标签相反的顺序关闭它们。 例如,在下面的示例中, <em>标签首先关闭,因为它是最后打开的标签。 <strong>标记是第一个打开的,因此最后关闭。

This sentence contains HTML elements that are <strong><em>nested according to best practices</em></strong>.

As a counter example, the following HTML code contains tags that are not nested according to best practices, as the <strong> tag closes before the <em> tag:

作为反例,以下HTML代码包含根据最佳实践嵌套的标记,因为<strong>标记 <em>标记之前关闭:

This sentence contains HTML elements that are <strong><em>not nested according to best practices</strong></em>.

While not technically necessary for rendering your HTML in the browser, nesting your tags in the proper order can help improve the readability of your HTML code for you or other developers.

尽管从技术上来说不需要在浏览器中呈现HTML,但按正确的顺序嵌套标签可以帮助您或其他开发人员提高HTML代码的可读性。

翻译自: https://www.digitalocean.com/community/tutorials/how-to-nest-html-elements


http://www.niftyadmin.cn/n/3647805.html

相关文章

高效率视频播放: GPU支持的YUV RGB 转化例子(2)

最近一直在做视频的播放。尤其是HD的视频&#xff0c;即使是1024 x 576的视频播放在CPU消耗上是一个巨大的压力。更大的还有1920 x 1080的。在CPU的消耗上简直就是一个恶梦。 最近用DSHOW做了一个Demo。一般Dshow的例子里都是直接用VMR把视频播放出去。对于游戏开发人员跟视…

如何在React Native中将路由与React导航一起使用

介绍 (Introduction) React Navigation is a popular library for routing and navigation in a React Native application. React Navigation是一个流行的库&#xff0c;用于在React Native应用程序中进行路由和导航。 This library helps solve the problem of navigating b…

线程的优先级

这两天在用 mpg123改一个mp3的播放器。解码过程显然是要放到一个线程里的&#xff0c;于是改完mpg123的main函数后&#xff0c;就把它放到一个新启动的线程里去&#xff0c;主函数这么写的int main(){ MP3Lib_open("test.mp3"); MP3Lib_play(); While(…

css3失去焦点伪类_CSS:伪类内的焦点

css3失去焦点伪类介绍 (Introduction) Selecting a parent element has long been impossible to do using just CSS, but a pseudo-class, :focus-within, changes that story somewhat. It allows to style an element when it has focus, but also when any of its inner el…

绘制恒线速度的参数曲线

假设一条参数曲线和某个参数 t 相关。L: x f(t) y g(t)如果我们绘制这条参数曲线的时候的&#xff0c;t是按比例增加的话。可能点的分布会不均匀。那么按照什么公式来决定t的步长能让曲线的点分布均匀呢&#xff1f;首先我们对参数曲线公式进行微分。dx df(t)dy dg…

css遮罩mask_使用mask-image属性在CSS中遮罩图像

css遮罩maskWe covered the use of the clip-path property for clipping using CSS, so it’s only natural that we now go over masking. Contrary to clipping, where a part of an image or element is either completely invisible or completely visible, with masking …

css中让图片剪切居中_CSS中使用剪切路径进行剪切的简介

css中让图片剪切居中介绍 (Introduction) clip-path is a very interesting property that allows to clip the visible portion of SVG elements, images or any HTML element really. clip-path是一个非常有趣的属性&#xff0c;它允许剪切SVG元素&#xff0c;图像或任何HTML…

脚本与渲染器 .

一直以来都想做一个脚本驱动的渲染器.就是说可以用脚本定制渲染器的行为,比如创建多少个渲染队列,如何渲染.多少RenderTarget, 每个物体的材质也是一样. 要生成多少个Pass,每个Pass是立即渲染呢还是放到那个队列里 . 其实我是个很懒的人 ,这个想法早在去年就有了.一直拖到…