


I have been re-learning HTML recently, which can be regarded as a new understanding of HTML! Don't underestimate this thing, all web pages are based on it! Let’s summarize the nesting rules of HTML tags in detail. I hope it will be helpful to everyone.
There are many XHTML tags: div, ul, li, dl, dt, dd, h1~h6, p, a, addressa, span, strong... When we use these tags to build the page structure, They can be nested infinitely, but nesting also needs to have certain rules, and you cannot allow your own personal habits to be nested randomly - XHTML is not XML after all.
In the language of XHTML, we all know: ul tag contains li, dl tag contains dt and dd - the nesting rules of these fixed tags are very clear. However, there are still many tags that are independent and not bundled together, such as h1, div, p... So what are the nesting rules of these tags? Let’s talk about this topic today.
When it comes to the nesting rules of XHTML tags, we first need to know that there are two types of XHTML tags:
One type is called block-level elements (block)
The other type is called inline elements (inline, Many people also call it: inline, inline, line level, etc.)
The standard for dividing block-level elements and inline elements is very simple. Please put the following two lines of code into the body tag:
Browser rendering effect:
div1
div2
The two divs presented on the page occupy two rows of space. Unless they are floated or other settings are made, no one is next to each other. They are both domineering. occupies its own row of space - whenever you see this phenomenon in a tag, you can call it: block-level element (block);
Then put the following two lines of code into the body tag Here:
span1
span2
Browser rendering effect:
span1 span2
This time, the two spans are juxtaposed in a row. They are friendly, friendly and harmonious... With label behavior like this, we You can call them: inline elements;
The difference between block-level elements and inline elements:
·Block-level elements are generally used to build website architecture, layout, and carry content... …These major physical tasks are all block-level elements, which include the following tags:
address, blockquote, center, dir, div, dl, dt, dd, fieldset, form, h1~h6, hr , isindex, menu, noframes, noscript, ol, p, pre, table, ul
· Inline elements are generally used in certain details or parts of website content to "emphasize, distinguish styles, Superscript, subscript, anchor point, etc., the following tags are all inline elements:
a, abbr, acronym, b, bdo, big, br, cite, code, dfn, em, font ,i,img,input,kbd,label,q,s,samp,select,small,span,strike,strong,sub,sup,textarea,tt,u,var
· Block element and inline elements can be converted to each other. The conversion code is as follows:
display: block; /* Convert to block element*/
display: inline; /* Convert to inline element*/
· The CSS calling rules for block elements and inline elements are different (this article discusses tag nesting, so this knowledge point will not be explained).
After briefly understanding block elements and inline elements, the nesting rules of XHTML tags can be listed below:
1. Block elements can contain inline elements or certain block elements. But inline elements cannot contain block elements, they can only contain other inline elements:
—— Yes
< ;/span> —— Wrong
2. Block-level elements cannot be placed inside
:
- ol> —— Wrong
—— Wrong
3. There are several special block-level elements It can only contain inline elements and can no longer contain block-level elements. These special tags are:
h1, h2, h3, h4, h5, h6, p, dt
4. inside li Can contain div tags - This item does not need to be listed separately, but many people on the Internet are confused about this, so I will briefly explain it here:
Li and div tags are both containers for loading content and have equal status. , there is no level distinction (for example: strict hierarchies such as h1 and h2^_^). You must know that the li tag can even accommodate its parent ul or ol. Why do some people think that li cannot accommodate a div? Woolen cloth? Don't think that li is so stingy. Even though li looks quite thin, in fact, li has a big heart...
5. Block-level elements are juxtaposed with block-level elements, and inline elements are inline with inline elements. Juxtaposition:
—— Right< ;/div> —— Wrong

HTML(HyperTextMarkupLanguage)是用于创建Web页面的标准语言,它使用标签和属性来描述页面上的各种元素,例如文本、图像、表格和链接等等。但是,在处理HTML文本时,很难将其中的文本内容快速地提取出来用于后续的处理。这时,我们可以使用Python中的正则表达式来去除HTML标签,以达到快速提取纯文本的目的。在Python中,正则表

如何在Go语言中使用正则表达式提取HTML标签内容导读:正则表达式是一种强大的文本匹配工具,它在Go语言中也有着广泛的应用。在处理HTML标签的场景中,正则表达式可以帮助我们快速提取需要的内容。本文将介绍如何在Go语言中使用正则表达式提取HTML标签的内容,并给出相关代码示例。一、引入相关包首先,我们需要导入相关的包:regexp和fmt。regexp包提供

PHP是一种常用的服务器端脚本语言,广泛应用于网站开发和后端应用程序开发中。在开发网站或应用程序时,经常会遇到需要处理字符串中的HTML标签的情况。本文将介绍如何使用PHP去除字符串中的HTML标签,并提供具体的代码示例。为什么需要去除HTML标签?在处理用户输入或从数据库中获取的文本时,经常会包含HTML标签。有时候我们希望在显示文本时去除这些HTML标签

在PHP中,可以使用htmlentities()函数来转义html,能把字符转换为HTML实体,语法“htmlentities(string,flags,character-set,double_encode)”。PHP中也可以使用html_entity_decode()函数来反转义html,把HTML实体转换为字符。

String是Java中的final类,它是不可变的,这意味着我们不能改变对象本身,但我们可以更改对象的引用。可以使用String类的replaceAll()方法从给定字符串中删除HTML标签。我们可以使用正则表达式从给定字符串中删除HTML标记。从字符串中删除HTML标签后,它将返回一个字符串作为普通文本。语法publicStringreplaceAll(Stringregex,Stringreplacement)示例publicclassRemoveHTMLTagsTest{&nbs

我们可以轻松地在表格中添加HTML标签。HTML标签应放置在<td>标签内。例如,在<td>标签内添加段落<p>…</p>标签或其他可用标签。语法以下是在HTML表格中使用HTMl标记的语法。<td><p>Paragraphofthecontext</p><td>示例1下面给出了在HTML表格中使用HTML标签的示例。<!DOCTYPEhtml><html><head&g

PHP是一种高效的网页开发语言,其支持正则表达式功能,能够快速验证输入数据的有效性。在网页开发中,HTML是常见的标记语言,而对HTML标签进行验证,是网页表单验证的一种非常重要的方法。本文将介绍基本的HTML标签验证方法,以及如何使用PHP正则表达式进行验证。一、HTML标签基本结构HTML标签由尖括号包围的元素名称和属性组成,常见的标签包括p、a、div

HTML标签有<!DOCTYPE>、<html>、<head>、<title>、<meta>、<link>、<style>、<script>、<body>、<h1> - <h6>、<p>、<a>、<img>、<div>、<span>、<input>、<button>、<form


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

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

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),
