I. How CSS Works

Source: Internet
Author: User

CSS full name cascading style sheet, which is a computer language used to represent file styles such as HTML (an application of the standard Universal Markup Language) or XML (a subset of the standard Universal Markup Language). is to be able to really do the Web page performance and content separation of a style design language, the Web page can be the location of the object of precise pixel control, support for almost all font size style, with the ability to edit the Web object and model style, and be able to conduct preliminary interaction design, is currently based on text display the best performance design language.

CSS Rules

A CSS document consists of a series of rules, a CSS rule is actually a CSS directive, which first selects the HTML element and then sets the style of the selection element.

Here is a simple CSS rule that sets the background color of the paragraph to green

P {background-colorGreen}
CSS Basic rules

A CSS rule consists of a selector + declaration two parts

Selector: Indicates the element to select

Declaration: consists of a property and a value, which indicates which aspect of the element is affected, and the value is actually a state of the attribute.

In the example above you can see that a rule is from left to right: selectors, left brackets, attributes, colons, values, right curly braces extend 1 to the basic rule: multiple declarations are included in a rule

P {colorgreen; font-size 45px; Font-weight Bold}

Add a semicolon after each declaration to separate

Extension 2 to basic rule: multiple selectors grouped together

H1,h3,p{colorgreen;  Font-size45px; Font-weight Bold}

The selectors are separated by commas
Extension 3 to basic rule: multiple rules applied to the same selector

H1,h3,p{colorgreen;  Font-size45px; Font-weight Bold}

Now we want the background color of the p paragraph to be blue, and we can continue to add a rule

P {background-colorBlue}
CSS Selector categories

All selectors for selecting a specific element are divided into three types: context selector, ID and class selector, attribute selector

Context 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.