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

What is the grammatical structure of css?

May 18, 2019 am 11:13 AM
css Grammatical structures

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 <div id="main">, 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!

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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What does placeholder mean in vue What does placeholder mean in vue May 07, 2024 am 09:57 AM

What does placeholder mean in vue

How to write spaces in vue How to write spaces in vue Apr 30, 2024 am 05:42 AM

How to write spaces in vue

How to get dom in vue How to get dom in vue Apr 30, 2024 am 05:36 AM

How to get dom in vue

What does span mean in js What does span mean in js May 06, 2024 am 11:42 AM

What does span mean in js

What does rem mean in js What does rem mean in js May 06, 2024 am 11:30 AM

What does rem mean in js

How to introduce images into vue How to introduce images into vue May 02, 2024 pm 10:48 PM

How to introduce images into vue

What is the function of span tag What is the function of span tag Apr 30, 2024 pm 01:54 PM

What is the function of span tag

What language is the browser plug-in written in? What language is the browser plug-in written in? May 08, 2024 pm 09:36 PM

What language is the browser plug-in written in?

See all articles