What is the effect of multiple IDs on the same page _css/html

Source: Internet
Author: User

We know that when a style sheet defines a style, you can define the ID and define class, for example:

Id Method: #test {color: #333333}, calling content on the page


Class method:. Test{color: #333333}, calling content on the page

ID A page can be used only once, class can be referenced multiple times.

Some netizens asked, ID and class as if nothing different, I used in the page with multiple IDs in IE show also normal, with multiple IDs what effect?

Answer: The first effect is the inability to pass the W3 check.

In the page display, the current browser also allows you to make this error, with multiple identical id "under normal circumstances" can also be displayed. But when you need to use JavaScript to control the DIV with the ID, there will be an error.

ID is a label that distinguishes between different structures and content, just like your name, if a room has 2 people with the same name, there will be confusion;
Class is a style that can be set on any structure or content, just like a dress;
Conceptually, it's not the same:
ID is the first to find the structure/content, and then define the style; class is to first define a style and then set it to multiple structures/content.

Web standards want everyone to write code in strict habits,

For example: You can use the display bold, but also can be used to display, but the consortium recommends that everyone use, because more semantic

It doesn't matter if you don't pay attention to these details.
Then you don't have to transition to XML, and you don't need to learn web standards, because Web Standard apps start with changes in these little details, or do you use HTML now?

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.