Home > Article > Web Front-end > Code for spaces in css
Code for spaces in CSS
In CSS, spaces are used to separate selectors, properties, and values.
Selector spaces
Simple selectors: Spaces are used to separate different simple selectors. For example:
<code>div p { color: red; }</code>
Nested selectors: Spaces are used to separate nested selectors. For example:
<code>div > p { color: blue; }</code>
Adjacent selectors: Spaces are used to separate adjacent selectors. For example:
<code>p + h1 { font-size: 1.5em; }</code>
Properties and values spaces
Properties and values: Spaces are used for Separate properties and values. For example:
<code>color: red; font-size: 20px;</code>
Code Example
Consider the following HTML code:
<code><div> <h1>标题</h1> <p>段落</p> </div></code>
To make the headings blue, the paragraphs are In green, we can use the following CSS code:
<code>div h1 { color: blue; } div p { color: green; }</code>
In this code, spaces are used to separate selectors, properties, and values.
The above is the detailed content of Code for spaces in css. For more information, please follow other related articles on the PHP Chinese website!