CSS Learning Notes

Source: Internet
Author: User

1. Three styles of CSS style code insertion:

Priority, remember their priorities:内联式 > 嵌入式 > 外部式

But embedded > external has a premise: the placement of the embedded CSS style must be behind the exterior.

in fact, in conclusion, it is --就近原则(离被设置元素越近优先级别越高) .

2 . Differences between class and ID selectors

The ID selector can only be used once in a document . Unlike class selectors, an ID selector can only be used once, and only once, in an HTML document. The class selector can be used more than once.

A1: What is the main difference between the two?

ID you can only use to define a single element, define two later. There is no problem with the page, but W3 detects that your page does not conform to the standard; class is classes, and the same class can define multiple elements. As far as the page effect is concerned, the visual effects of two items are almost no different.

Why is the a2:id selector less used, and what are its limitations?

Single use of the style with ID, need to program, JS dynamic control style with Id,id in the page can only be used once! Provide a less-used ID because the ID may conflict with a page-embedded program (such as the same name)!

A3: When should I use my id and when do I use class?

A single element, or something that requires a program or JS control, needs to be defined with an ID, a reusable element, a class, and a class definition.

CSS Learning Notes

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.