Nine Grouping and Nesting grouped and nested

Source: Internet
Author: User
Group

Grouping Group

When many selectors have the same properties, you can combine them with commas.

Example

h2 {color: red;}.thisOtherClass {color: red;}.yetAnotherClass {color: red;}

The above can be written like this:

h2, .thisOtherClass, .yetAnotherClass {color: red;}

Nesting nesting

If the CSS structure is good, you don't need to use many class or ID selectors. This is because CSS can set the selector's properties inside the selector.

Example:

#top {background-color: #ccc;padding: 1em}#top h1 {color: #ff0;}#top p {color: red;font-weight: bold;}

If you come across the form below, remember to dispose of the class or ID on your page.

<div id="top">Chocolate curry<p>This is my recipe for making curry purely with chocolate</p><p>Mmm mm mmmmm</p></div>

This is because, by using the space separator selector, we can set top the ID inside the h1 color #ff0 for, p Yes red and blod .

This can be complicated, because nesting can be used multilevel, so you need to practice more.

Here's a detailed introduction to IE7 's new supported selectors.







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.