CSS intermediate course combination and nesting

Source: Internet
Author: User

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;

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>

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.