CSS [General selector] and [nesting selector]

Source: Internet
Author: User

[General selector]

There is another method that must be mentioned for the general selector to ensure that the page is compatible with multiple browsers,
So to reset all the tags in the HTML, the followingCodeAdd to the top of the CSS file

* {Margin: 0; padding: 0 ;}

Why is it so useful? Because each browser has its own CSS file. If a page loads a page in the browser
If no CSS file is found, the browser will automatically call its own CSS file, but different
The CSS files in the browser are different, and the styles defined for different labels are different. If we want to make
The page can display the same effect in different browsers, so we need to repeat the HTML Tag
Is the code above, but this is also a bad thing, because html4.01 has 89 labels, so
This is equivalent to adding the 89 tags to the page when loading CSS.{Margin: 0; padding: 0 ;},
I do not recommend that you do this here, because there are a few tags to be reset in 89 tags, and there is no need
All tags are reset. You can reset the tags that need to be reset, as shown below:

  1 Body, Div, P, A, UL, Li{Margin:0;Padding:0;}
2  

If you still need to reset the DL, DT, and DD labels, you can add them as follows:

  1 Body, Div, P, A, UL, Li, DL, DT, dd{Margin:0;Padding:0;}
2  

If you use it, you can also consider it as a measure of the page level produced by PAGE reconfigurator, and whether it is specialized
Industry.
Now, you should understand that the general selector is the most powerful but the least selector.
~ Pai_^
OK! I should have understood the content of the selector. I will continue to explain the collective sound of the selector.
Specify "and" nesting selector ".

========================================================== ==================================

[Nesting selector]

Selectors can also be nested, such:

 
  # Div1 P{Color:#900;}
/*The text color of the link a label in the p label with ID div1 is red.*/

The advantage is that you do not need to define a label separately in the p label of the label with ID div1.
Class selector or ID selector. CSS code is missing ~ It is also a part of CSS code optimization.

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.