Home  >  Article  >  Web Front-end  >  What is the grammatical structure of css?

What is the grammatical structure of css?

青灯夜游
青灯夜游Original
2019-05-18 11:13:006100browse

What is the grammatical structure of css?

The grammatical structure of CSS only consists of three parts: selector (Selector), attribute (property), and value (value).

Usage syntax:

selector {Property:value;}

The selector (Selector) refers to the object to be targeted by this set of style coding. It can be an XHTML tag, such as body, h1; it can also define a specific ID Or the CLASS tag, such as the #main selector, which means selecting 243a8f3f087936dc3f96e2f0cf018c22, that is, an object with main as the id specified. The browser will strictly parse the CSS selectors, and each set of styles will be applied to the corresponding object by the browser.

Property is the core of CSS style control. For each tag in XHTML, CSS provides rich style attributes, such as color, size, positioning, floating method, etc.

Value (value) refers to the value of the attribute. There are two forms. One is the value of the specified range, such as the float attribute. Only three values ​​​​of left, right, and none can be applied, such as width. It can be specified using 0-9999, or other mathematical units.

In practical applications, we often use the following similar application forms:

body {background-color:blue;}

Explanation:

The body{} above is a type selector. The so-called type selector refers to the selector that uses the existing tag type in the web page as its name. Body is a tag type in the web page, so is div, and so is span. Therefore, the following selectors are all type selectors, and they will control all bodies, divs, or spans in the page:

body{}
div{}
span{}

The above is the detailed content of What is the grammatical structure of css?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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