Combination
You do not have to repeat multiple delimiters with the same attributes. You only need to use commas (,) to separate the delimiters.
For example, you have the following code:
The code is as follows: |
Copy code |
H2 { Color: red; } . ThisOtherClass { Color: red; } . YetAnotherClass { Color: red; } You can write as follows: H2,. thisOtherClass,. yetAnotherClass { Color: red; } |
Nesting
If the CSS structure is good, there is no need to use too many classes or identifiers. This is because you can specify the separator in the separator. (Or better argument, context selector-translated)
For example:
The code is as follows: |
Copy code |
# Top { Background-color: # ccc; Padding: 1em } # Top h1 { Color: # ff0; } # Top p { Color: red; Font-weight: bold; }
|
This removes unnecessary classes or Identifiers. If it is applied to HTML like this:
The code is as follows: |
Copy code |
<Div id = "top"> <H1> Chocolate curry <P> This is my recipe for making curry purely with chocolate </p> <P> Mmm mmmmm </p> </Div>
|
This is because the English halfwidth space separator indicates that h1 in the id has the color of "# ff0", while p is red and bold.
This may also be complicated (because it may be more than two levels, for example, inside and so on ). You need to exercise more.