Home >Web Front-end >CSS Tutorial >How to write css style code
CSS is a style sheet language used to describe the visual presentation of HTML elements. Syntax structure: Selector: Specify the HTML element to apply the style Attributes: Set the visual attribute value of the element: Set the specific value of the attribute
CSS style Writing code
CSS (Cascading Style Sheets) is a style sheet language used to describe the visual presentation of HTML elements. Its syntax is simple and easy to understand, and the code is easy to write.
Syntax structure
CSS style code consists of three parts:
Writing Format
CSS style code is usually written in the following format:
<code>选择器 { 属性1: 值1; 属性2: 值2; ... }</code>
Step Guide
p
. color
and the value blue
: <code>p { color: blue; }</code>
Notes
Example
The following CSS code will set the <h1>
and <h2>
elements The font is red and the font for paragraph elements is green:
<code>h1, h2 { color: red; } p { color: green; }</code>
The above is the detailed content of How to write css style code. For more information, please follow other related articles on the PHP Chinese website!