When many people just get started with CSS, they don’t quite understand the rules of CSS grammar, and they don’t know what the rules of CSS grammar consist of. Let’s explain what the rules of CSS grammar consist of?
css is mainly composed of two parts. The first is the selector, and the second is the statement. The statement may be one or many, and the css selector is When we change the style of html, each statement consists of an attribute and a value. The main syntax of css is:
selector {declaration1; declaration2; ... declarationN }
Below we can use a case to illustrate the rules of css:
h1 {color:red; font-size:16px;}
In the above code, h1 represents the selector, and the statement inside the curly braces is the attribute. and value, where color is the attribute of css, and red is the value. There are several ways to write the value. We know that there are several ways to write red. We can also use hexadecimal #ff0000 to express it. Of course we want to use Less bytes can also be represented by CSS abbreviations. Sometimes we can also use RGB percentages. When using percentages, we have to write the percentage symbol.
The most important thing about css is multiple declarations. If we want to define several declarations, we can use the declaration symbols to separate them. The last attribute does not need to be added with a semicolon. The semicolon in English is A separator symbol is not an end symbol, but many experienced people like to add a separator symbol. This may reduce our chances of making mistakes. For example:
p { text-align: center; color: black; font-family: arial; }
Finally we must pay attention to spaces and case. Many styles have more than one statement, so no spaces should appear. If css involves working with html, the class in css is very sensitive.
The above is a complete introduction to getting started with css: what css grammar rules consist of. If you want to know more about CSS tutorial and CSS3 tutorial, please pay attention to php Chinese website.
The above is the detailed content of Introduction to css: What do css grammar rules consist of?. For more information, please follow other related articles on the PHP Chinese website!