Summary:
1, block elements can contain inline elements or some block elements (the above example is actually a wrong use--->I put inside )
##2 ,The DTD we use stipulates that block-level elements cannot be placed inside
##3. Key points: three levels of block elements
4. img of inline elements They are special compared to input. They have width and height that inline elements do not have. W3C defines it as a replace element. Setting the element to display:inline-block simulates the effect of the replace element.
cause: When I was working on a project, I found that the code that was originally correct in DW was in MyEclipse6.0 but prompted N So many mistakes, so surprising. So after investigating the reason, we found that p cannot be nested within block-level element P.
Go deeper: Let’s first understand in-line elements and block-line block elements, because almost all elements in HTML are inline elements or blocks One of the elements.
The word in-line has many interpretations: inline, inline, inline, line level, etc., but they all mean the same thing means, here we choose the customary name - inline.
You can understand the difference between the two by looking at the following example:
Test it Differences between block elements and inline elements
Test the difference between block elements
## The effect is as follows:
In the above example,
will Generate a new line by itself, and does not break. This is only the case without CSS rendering. Similarly, we can also define p as an inline element and span as a block element through CSS. However, we cannot convert them arbitrarily in HTML. Block elements can contain inline elements or certain block elements (the above example is actually a wrong use--->I put in inside), , look at this again: ##Where can contain , and it is correct for
There are also situations where some block elements cannot contain other block elements. For example:
And this is okay.
Why? Because the DTD we use stipulates that block-level elements cannot be placed inside , and some browsers condone such writing: 当一个 签还没结束时,遇到下一个块元素就会把自己结束掉,其实浏览器是把它们处理成这样: 所以刚才那样的写法会变成这样: 这也是跟刚才说第一个例子中 里面放 不合理是同一个道理。 以下为重点理解部分: 那哪些块元素里面不能放哪些块元素呢?我知道你有这个疑问,也知道我仅仅列一张清单你不好记住它们。我们可以先把所有的块元素再次划分成几个级别的,我们已经知道是在最外层,下一级里面只会有head<h2 id="我喜欢在-a-nbsp-href-nbsp-经典论坛-a-讨论Web标准的原因">我喜欢在<a href="#" >经典论坛</a>讨论Web标准的原因。</h2>
is a block element, and is an inline element. There is no error in
including . Similarly,
<a href="#"> <h2 id="这样是错误的用法">这样是错误的用法!</h2></a>
<p>测试文字
<ul>
<li>现阶段是不能这样用的,要等到XHTML 2.0才可以这样用。</li>
</ul>
测试文字
</p>
<ul>
<li><p>这样是可以的</p></li>
</ul>
<p>这是一个段落的开始
<p>这是另一个段落的开始
<p>这是一个段落的开始</p>
<p>这是另一个段落的开始</p>
<p>测试文字</p>
<ul>
<li>现阶段是不能这样用的,要等到XHTML 2.0才可以这样用。</li>
</ul>
测试文字<p></p>
为什么说第二级的元素可以自由嵌套呢?我们可以把它们看成是一些容器(或者说是盒子), 这些容器的大小可以自由变化,例如我们可以把 里面,也可以把 嵌在嵌在
There are several elements in HTML that are quite special: This is also the reason why many people fail to pass W3C validation--> Wrong element nesting, but change the label that prompts the error to or It can pass, but we cannot blindly verify for the sake of verification, is not a god, cannot replace the semantic tag. In fact, among inline elements, you can still distinguish them. There are several Elements (,
,
,
, their sub-levels must be designated elements, and
must be
must be
must be or ,
,
, etc., and the next sub-layer must be
(
only exists in ,
, ), followed by or
where content can be placed.
, , etc.) are special, they can define width and height. Although in IE
In the browser, all elements can define width and height, but this is IE's own standard, not all browsers support it, W3C calls them replaced elements, I can't find a word suitable for translation. , they also have some characteristics of block-line when they are in-line. The inline-block mentioned in "desplay: application of inline-block" actually allows other elements to be simulated as replaced elements. You can temporarily Don’t know too much about it, just learn it later.
The above is the detailed content of Why can't DIV tags be included in the P tag in html?. For more information, please follow other related articles on the PHP Chinese website!

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.


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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 English version
Recommended: Win version, supports code prompts!

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