Beginner: carefully studying CSS selection characters for web pages

Source: Internet
Author: User

Wildcard character
Syntax:
 
*
 
Note:
 
Select all types of single objects in the document directory tree (DOM.
If the wildcard character is not the only component of a single character, "*" can be omitted.
Currently, IE5.5 + does not support this selection character.
 
Example:
 
* [Lang = fr] {font-size: 14px; width: 120px ;}
*. Div {text-decoration: none ;}
Type selector
Syntax:
 
E1
 
Note:
 
The document language object type is used as the selector.
 
Example:
 
Td {font-size: 14px; width: 120px ;}
A {text-decoration: none ;}
Attribute selector
Syntax:
 
1. E1 [attr]
2. E1 [attr = value]
3. E1 [attr ~ = Value]
4. E1 [attr | = value]
 
Note:
 
1. Select E1 with the attr attribute
2. Select E1 with the attr attribute and the attribute value is equal to the value.
3. Select the word list with the attr attribute and the attribute value is separated by spaces. One of the words is equal to the value of E1. The value here cannot contain spaces
4. Select the word list with the attr attribute and the attribute value is separated by a hyphen. The E1
Currently, IE5.5 + does not support this selection character.
 
Example:
 
H [title] {color: blue ;}
/* All h objects with the title attribute */
Span [class = demo] {color: red ;}
Div [speed = "fast"] [dorun = "no"] {color: red ;}
A [rel ~ = "Copyright"] {color: black ;}
Include selector
Syntax:
 
E1 E2
 
Note:
 
Select all E2 contained by E1. That is, E1.contains (E2) = true.
 
Example:
 
Table td {font-size: 14px ;}
Div. sub a {font-size: 14px ;}
Sub-object selector
Syntax:
 
E1> E2
 
Note:
 
Select E2 for all E1 sub-objects.
Currently, IE5.5 + does not support this selection character.
 
Example:
 
Body> p {font-size: 14px ;}
/* The font size of all p objects as sub-objects of the body is 14px */
 
Div ul> li p {font-size: 14px ;}
ID selector
Syntax:
 
# SID
 
Note:
 
Take the ID of the object as the unique identifier in the document directory tree (DOM) as the selector.

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.