Home  >  Article  >  Web Front-end  >  What does css style consist of

What does css style consist of

醉折花枝作酒筹
醉折花枝作酒筹Original
2021-07-15 11:20:095580browse

CSS style consists of three parts: selector, attribute and value. The selector is usually the HTML element or tag you wish to define, the attributes are the properties you wish to change, and each property has a value. Properties and values ​​are separated by colons and surrounded by curly braces, thus forming a complete style declaration.

What does css style consist of

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

CSS syntax consists of three parts: selector, attribute and value.

selector {property: value}

Selector {Attribute:Attribute value}

The selector (selector) is usually the HTML element or tag you want to define, and the attribute (property) is the attribute you want to change, and each Each attribute has a value. Properties and values ​​are separated by colons and surrounded by curly braces, thus forming a complete style declaration.

Example:

body {color: blue}

The function of the above line of code is to define the text color within the body element as blue. In the above example, the body is the selector and the part enclosed in curly braces is the declaration. The declaration consists of two parts: attributes and values. Color is the attribute and blue is the value.

CSS code consists of selectors and one or more declarations, which in turn consist of attributes and values. It can also be said that css code consists of selectors, attributes, and values, such as the following code example:

选择器 {
    属性1: 值1;
    属性2: 值2;
    ……
}
.div1 {
    width: 100px;
    height: 200px;
}

selector.div1

Attribute width value 100px

Attribute height value 200px

Recommended learning: css video tutorial

The above is the detailed content of What does css style consist of. 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
Previous article:why css doesn't workNext article:why css doesn't work