What does css3 grammar rules consist of?

青灯夜游
Release: 2021-12-15 17:21:00
Original
2564 people have browsed it

css3 grammar rules consist of three parts: "selector", "attribute" and "attribute value". "Selector" specifies the object to be targeted by CSS style coding, "property" is the set style option provided by CSS, and "property value" is a parameter used to display the effect of the property.

What does css3 grammar rules consist of?

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

Style is the smallest syntax unit of CSS. CSS syntax consists of three parts: selector, attribute and attribute value.

What does css3 grammar rules consist of?

  • Selector

    Specify the object to be targeted by this set of style coding, which can be an XHTML tag or It is a tag of a specific id or class (preceded by #);

  • Attribute (Property)

    attribute is the core of CSS style control, and is used in every XHTML Both labels and CSS provide rich style attributes, such as color, size, positioning, floating method, etc.

    Attributes are set style options provided by CSS. The attribute name consists of one or more words, and multiple words are connected by hyphens. This can intuitively represent the effect of the attribute to be styled.

  • Attribute value (value)

    refers to the value of the attribute, which is a parameter used to display the effect of the attribute. It includes numerical values ​​and units, or keywords.

Different writing methods and units of values

In addition to the English word red, we can also use hexadecimal Color value #ff0000:

p { color: #ff0000; }
Copy after login

In order to save bytes, we can use the CSS abbreviation:

p { color: #f00; }
Copy after login

We can also use RGB values ​​in two ways:

p { color: rgb(255,0,0); }
p { color: rgb(100%,0%,0%); }
Copy after login

Note that when using RGB percentages, the percent sign is written even when the value is 0. But in other cases there is no need to do this. For example, when the size is 0 pixels, there is no need to use px units after 0, because 0 is 0, no matter what the unit is.

Remember to write quotation marks

Tip: If the value is several words, add quotation marks to the value:

p {font-family: "sans serif";}
Copy after login

CSS Advanced syntax: Grouping selectors

You can group selectors so that grouped selectors share the same declaration.

Use commas to separate the selectors that need to be grouped. In the example below, we have grouped all heading elements. All title elements are green.

h1,h2,h2,h3,h5,h6 {
color: green;
}
Copy after login

(Learning video sharing: css video tutorial)

The above is the detailed content of What does css3 grammar rules consist of?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template