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

What is the grammatical structure of css?

青灯夜游
Release: 2019-05-23 18:44:08
Original
6201 people have browsed it

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;}
Copy after login

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

, 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;}
Copy after login

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{}
Copy after login

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!

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