CSS Parent-Child Selector

Source: Internet
Author: User

(1) Parent-child selector can have multi-level, but the actual application does not recommend too much, not more than three layers.

(2) The parent-child selector has a strict hierarchical relationship.

(3) A parent-child selector can be a combination of many types of selectors, such as:

#id span Span

. CLS1 #id Span

Div #id. style1

(4) When using a parent-child selector, the following sentence is used for the header of the HTML file:

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"
"Http://www.w3.org/TR/html4/loose.dtd" >

The following example is a three-layer,<div> for the parent,<span>,<a> for the Sun

Cases:

HTML file:

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"
"Http://www.w3.org/TR/html4/loose.dtd" >
<title> Parent-Child selector </title>
<link rel= "stylesheet" type= "Text/css" href= "Test.css"/>
<body>
<div id= "ID1" ><span> Thank you for visiting <a href= "http://www.bianceng.cn" >www.bianceng.cn</a></span , hope to help you! </div>
</body>

Content of Test.css:

/* Parent-Child Selector * *
#id1 {
Background-color:silver;
font-size:20px;
Color:black;
}
#id1 span{
color:red;
Font-style:italic;
}
#id1 span a{
Color:green;
Text-decoration:none;
}

The effect of the following figure:

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/web/Css/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.