css--Selector

Source: Internet
Author: User

    • CSS Selector

Selector,selector,selector {Property:value;property:value ...}


CSS Selectors can be divided into two main categories: (signature, attribute)
A. basic selector: Wildcard, tag, ID, class and attribute selector
B. Combo selector: Group selector, descendant selector, child selector, and adjacent sibling selector. Also called derived selectors: Use the format of the parent element child element to navigate to a child element under a specific parent element.

Here is a copy of HTML:


    • 1. Basic Selector

1) tag Selector with tag name as selector
h2 {color:red;} div {color:red;}

2) The ID selector applies a style to a label that specifies the ID property value, starting with # to define
#p1 {color: #00ff00; font-size:40px;}

3) Class selector to apply styles to certain tags of the specified class property value, starting with the.
. cs {Color:blue;}

4) The property Selector Property Selector allows you to select elements based on their attributes [and property values].
A. Match by property name, and include the property name in [].
[Title] {color:gray;font-size:20px;}


B. match by property name and property value, and include the property name and value in []

[title= ' DT '] {color:gray;font-size:20px;}

5) Wildcard selector to configure any label
* {font-size:30px;}

    • 2. Combo Selector
1) The group selector applies the specified style at the same time for multiple labels or multi-class labels, separated by the middle
H2, #p1,. cs {color:green;}


2) Descendant selectors can be found as long as they are descendants, no matter how many layers.
Div span {color:blue;} <div title= "DT" >

3) The child selector must be a direct sub-element here
Div>span {color:green;} <div title= "DT" >


4) Adjacent sibling selector
H3+span {color:orange;} <div title= "DT" >


5) Hyperlink Dependent selector


The default style for hyperlinks is blue, with the underline line added. Hyperlinks have the following 4 selectors:
A:link setting hyperlinks in deprecated CSS styles
A:hover setting CSS styles when the mouse hovers over a hyperlink
A:active CSS style When a hyperlink is set to be activated by the user (event between mouse click and release)
a:visited to set CSS styles for hyperlinks that have already been visited


Then the default hyperlink is blue with an underlined style, if I want the hyperlink to be black and not underlined, and then when the mouse moved to the top of the line when the underline, click on the hyperlink after the program red, so how to design the effect?




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.