


Why can't html P tags nest divs? There are also examples of css styles for html P tags
This article introduces the advanced version of the html p tag. Those who have not seen the basic version of the previous article can click on the link below to read it. This article mainly introduces the html p There are two important knowledge points about tags. One is how to use CSS styles to control the specific use of P tags. There are examples for each. Interested students can try the code by themselves. The other is why HTML P tags cannot be embedded. For a detailed explanation of the set of divs, I hope you will carefully read the
html P tag tag definition and usage instructions:
tag definition paragraph.
The element will automatically create some white space before and after it. The browser adds these spaces automatically, or you can specify them in your stylesheet.
html Attributes of P tag:
##Why can’t div tags be nested within P tags in HTML?
<p>测试一下块元素与<span>内联元素</span>的差别</p> <p>测试一下<div>块元素</div>与内联元素的差别</p>
<h2 id="我喜欢在-a-nbsp-href-http-www-php-cn-nbsp-nbsp-php中文网-a-讨论Web标准的原因">我喜欢在<a href="http://www.php.cn/ " >php中文网</a>讨论Web标准的原因。</h2>
belongs to the block element, and < a> is an inline element, and there is nothing wrong with including . Similarly, can contain , and it is also correct for
There are also cases where some block elements cannot contain other block elements. For example: <p>测试文字
< ul>
li>现阶段是不能这样用的,要等到XHTML 2.0才可以这样用。</li>
</ul>
测试文字
</p>
Copy after login And this is okay. <ul>
<li><p>这样是可以的</p></li>
</ul>
Copy after login Why? Because the DTD we use stipulates that block-level elements cannot be placed inside , and some browsers condone this writing:
This is the beginning of a paragraph
This is the beginning of another paragraph
When a tag has not ended, it will end itself when it encounters the next block element. In fact, the browser They are processed like this:
<p>这是一个段落的开始</p>
<p>这是另一个段落的开始</p>
Copy after loginSo the writing method just now will become like this: <p>测试文字</p>
<ul>
<li>现阶段是不能这样用的,要等到XHTML 2.0才可以这样用。</li>
</ul>
Copy after loginTest textThis is also It’s the same reason as what I just said about putting inside in the first example.
So which block elements cannot be placed inside which block elements? I know you have this question, and I know it's hard for you to remember them if I just make a list. We can first divide all the block elements into several levels again. We already know that is in the outermost layer, and the next level of will only have , ,
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
, and it is also correct for
There are also cases where some block elements cannot contain other block elements. For example:<p>测试文字 < ul> li>现阶段是不能这样用的,要等到XHTML 2.0才可以这样用。</li> </ul> 测试文字 </p>
<ul> <li><p>这样是可以的</p></li> </ul>
, and some browsers condone this writing:
This is the beginning of a paragraph
This is the beginning of another paragraph
When atag has not ended, it will end itself when it encounters the next block element. In fact, the browser They are processed like this:
<p>这是一个段落的开始</p> <p>这是另一个段落的开始</p>
<p>测试文字</p> <ul> <li>现阶段是不能这样用的,要等到XHTML 2.0才可以这样用。</li> </ul>
in the first example.
So which block elements cannot be placed inside which block elements? I know you have this question, and I know it's hard for you to remember them if I just make a list. We can first divide all the block elements into several levels again. We already know that is in the outermost layer, and the next level of will only have , ,
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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics



Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.
