CSS combination Selector

Source: Internet
Author: User

CSS combination Selector

1. Select all descendant elements with spaces

Div p

{
Background-color: yellow;
}

Select all descendant p elements of the div element, which can be child elements and child elements...

 

2. Greater than Id> select all direct child layer elements

Div> p
{
Background-color: yellow;
}

Select all direct child elements of the div element, with only one child element

 

3. Wave Number ~ Select All sibling elements at the same Layer
Div ~ P
{
Background-color: yellow;
}

Select All sibling elements in the same layer of the div Element

 

4. plus sign + select the first sibling element of the same Layer

Div + p
{
Background-color: yellow;
}

Select the first sibling element of the same layer of the div element.

 

5. p: first-child select the first p element

P: first-child
{
Color: blue;
}

Select the first p element.

 

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.