[Learning Notes] CSS Selector

Source: Internet
Author: User

CSS syntax structure
selector {property1:value; Property2:value;} If you have more than one property, you need a semicolon at the end of each property. If the value of a property is made up of multiple words, you need to enclose multiple words in quotation marks.types of selectors:
    • Element selector-Select HTML element directly: h1{}, a{}
    • Selector grouping-You can set the same style for multiple types of labels: h1,a{}
    • Wildcard-Sets the style for all HTML tags. A common practice is to use wildcards to set margin and padding to 0px: *{}
    • Class Selector-use the. ClassName to specify a class style, which is set in HTML by Class=classname:. class{}
    • Element selector + Class Selector-Select the element of a specific type that specifies the class selector: a.class{}
    • Multi-class selectors-as the name implies, multiple class styles are applied on the HTML tag. specified in HTML by class= "Class1 Class2" in the style sheet format:. class1.class2{}
    • ID Selector-To specify a style for a specific property by #id, simply set the ID for the HTML tag: #id {}
    • Property Selector-Specifies the style for HTML with the specified property: [Properties] {}
    • Properties and value selectors-similar to the property selector, and attaching a qualification specifies a value for a specific property: [property = value] {}
    • Partial property value selector-similar to the property and value selector, in which case only the value of the property is included with the given value: [property~=value]{}
    • Descendant Selector-Select the descendant of an element (including child, descendant, descendant, ...): div p a{}, select the A element below the P element below the DIV element
    • Child element Selector-Select the child element of an element (only direct descendants can be selected): p>strong{}
    • Adjacent sibling selector-selects the element immediately following an element and has the same parent element: h1+p{}, the same level as H1 and immediately following the P element that appears after H1
    • Inheritance: Child elements will inherit the style defined on the parent element

[Learning Notes] CSS Selector

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.