Home > Web Front-end > Front-end Q&A > What is parent tag in html5

What is parent tag in html5

WBOY
Release: 2022-01-23 15:04:43
Original
2990 people have browsed it

In HTML5, when a tag is wrapped by another tag, the wrapped tag is called the parent tag of the wrapped tag; the wrapped tag is called the child tag of the outer wrapping tag, syntax is "".

What is parent tag in html5

The operating environment of this tutorial: Windows 10 system, HTML5 version, Dell G3 computer.

What is the parent tag in html5

For example:

<div>
<p></p>
</div>
Copy after login

Relative to p, div is its parent tag

Double tag Relationships can be divided into two categories:

Father-child relationship (nested relationship)

The parent-child relationship is to nest other elements within a double label, then the elements nested in it are equivalent to "child ", its outer element is equivalent to "parent".

Brother relationship (parallel relationship)

Brother relationship means that there are multiple parallel elements in the "parent tag", and the relationship between these parallel elements is brotherhood.

Parent element, child element, brother element, descendant element

As you can see from the above parent-child relationship, the element equivalent to "father" is the parent element, and the nested element is the child. Element

If multiple elements are nested, then these multiple elements are brothers of each other.

The descendant elements are the child elements within the child element, and the child elements of the child element are its outer layer. Descendants of the element's parent element

talk is cheap, show you(me) the code

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
    <!-- <div>是<body>的子元素 ,<body>是父元素,<body>和<div>是父子关系-->
        <h1>这是后代元素1</h1>
        <p>这是后代元素2,和后代元素1是兄弟关系,并且互为兄弟元素</p>
    </div>
</body>
</html>
Copy after login

Recommended tutorial: "html video tutorial"

The above is the detailed content of What is parent tag in html5. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template