CSS Basic Selector

Source: Internet
Author: User
<! DOCTYPE html>

/*id selector: Select the only element in the page, it is recommended that the same ID identifier is allowed only once */

#item1 {/*background-color:red;*/}

/* Class selector: Select all elements in the page that have the same type of style */

. Green {/*background-color:lightgreen;*/}

/* Parent-Child selector: The element is a hierarchical relationship, the selected element has a common parent */

UL li {/  * * Hierarchical relationship with a space to denote */color:white;}

/* Wildcard selector: Select the element at all levels below the specified parent */

UL * {/*border:1px solid black;*/}

/* child element selector;: Selects all LI elements under the parent element, equivalent to the tag selector, so its priority is lower than class,id*/

ul > li {   /* equivalent to: ul > * {} *//*background-color:blue;*/}

/* Adjacent Sibling selector +: Select only the first sibling node relative to it */

#item2 + li {/*background-color:black;/* Only a 7th ball turns black */*/}

/* All Brothers Selector ~: Select all sibling nodes relative to it */

 #item2 ~ li {/*background-color:coral;/* bright orange */*/}</style>

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.