CSS Learning (1) Selector

Source: Internet
Author: User

Using CSS

1,css is a cascading style sheet (cascading style Sheet), consisting of a selector and a declaration block. The first section below H1 is the selector, and the curly braces surround the block that is the declaration block.

{    color: red;}

2,css use is mainly divided into external style sheets, embedded style sheets, and inline style sheets.

/* external style sheet */ <link rel= "stylesheet" href= "Base.css" > /* Embedding Style Sheets */ <style>     {        color: red;    } </style> /* Inline style sheet */ 

3, the selector is used to determine which elements the style sheet is to be applied to. There are five types of selector categories available: element name, category, pseudo class, attribute, ID

(1) On the priority level, the ID is the highest priority, the element name is the lowest, and the category and attribute are the same.

(2) The selector can be used in combination. The blend selector priority is calculated from the right to the left. For example, H1.very is higher priority than very h1, so the elements that satisfy both are preferred to use the h1.very style. If the priority level is the same, the style that appears after use

(3) Mixed use selector:

A, element name: combined with a homogeneous selector, which represents a parent-child element relationship separated by a space, and a comma-separated representation of an equal relationship

B, category with dot number + class name

C, pseudo-class using Colon + pseudo-class name

D, the property uses [name= "value"] property value is not filled when [name] means that the property value is not restricted, the available matching patterns are =, ~=, |=, *=, ^=, $=

E,id with #id

/* H1,H2 Elements */  /* H1 all H2 child elements */*/*H1 direct H2 child elements * / /* * */*H1 behind the half-element H2 element *  /  { }

CSS Learning (1) 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.