Home  >  Article  >  Web Front-end  >  Can html p tag contain a tag? Description of the role of html p tag

Can html p tag contain a tag? Description of the role of html p tag

寻∝梦
寻∝梦Original
2018-08-29 13:38:5516122browse

This article mainly introduces the function of the HTML p tag. The

tag can contain the explanation of the tag. It also mainly explains the function of the HTML p tag. Now Let's take a look at this article

First of all, let's talk about whether the a tag can be included in the p tag?

Let’s first look at the

tag, which is a block-level element. It occupies an exclusive line and its width automatically fills the width of its parent element.

The tag is an inline element. It will not occupy a single line. Adjacent inline elements will be arranged in the same line. The line will not be broken until it cannot fit in one line. Its width changes with the content of the element.

Block-level elements can contain inline elements. , so the tag can be included in the

tag.

Here is an example where the

tag contains the tag:

<!doctype html>
<html>
 <head>
 <meta charset="UTF-8">
 <title>我是网页标题(我是PHP中文网)</title>
 </head>
 <body >
 <p>这里是PHP中文网<a href="http://www.php.cn">点击这里进入</a>这也是PHP中文网,点击中间的字</p>
 </body>
</html>

Here is the effect and the picture:

Can html p tag contain a tag? Description of the role of html p tag

The picture above is the picture that comes out of the code. The purple underlined one is the a tag of the hyperlink.

Now let’s talk about the role of the HTML p tag:

First of all, the

tag defines the paragraph.

The p 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.

Page tag usage:

You can specify paragraphs only within a block, or you can combine paragraphs with other paragraphs, lists, forms, and predefined formats used together with the text. In general, this means that paragraphs can appear anywhere there is appropriate text flow, such as in the body of the document, within list elements, etc.

From a technical point of view, paragraphs cannot appear in headers, anchors, or other places that strictly require content to be text only. In fact, most browsers ignore this restriction and format paragraphs as part of the content of the containing element.

In general, the

tag defines segments. There can be many paragraphs within a

tag.

There are also examples. This is an article I found on the Internet. I displayed it in sections:

<!doctype html>
<html>
 <head>
 <meta charset="UTF-8">
 <title>我是网页标题(我是PHP中文网)</title>
 </head>
 <body >
 <p>这里是PHP中文网<a href="http://www.php.cn">点击这里进入</a>这也是PHP中文网,点击中间的字</p>
<p>推进“一带一路”建设的5年,是成果丰硕的5年。习近平总书记指出,5年来的“一带一路”建设,推动我国形成陆海内外联动、东西双向互济的开放新格局。</p>
<p>黑龙江黑河边境经济合作区管委会主任 王海东:习近平总书记提出“政治互信、经济互融、人文互通”,本着这个原则,黑河利用独特的区域优势,从过去的一个边境走向了“一带一路”的前沿。</p>
<p>从落地生根到持久发展,习总书记在讲话中要求各地区加强与国家战略对接,这为各地更好对接“一带一路”建设指明了方向。</p>
</body>
</html>

You can see the effect:

Can html p tag contain a tag? Description of the role of html p tag You see, this is the role of the paragraph

tag, the content inside is the content of a paragraph.

Okay, the above is the entire content of our article. If you have any questions, you can ask below

[Editor’s recommendation]

How to add html The text in the pre tag is wrapped? Usage examples of html pre tag

What does the HTML ul tag mean? Detailed explanation of the role of HTML ul tag

The above is the detailed content of Can html p tag contain a tag? Description of the role of html p tag. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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