Home > Web Front-end > CSS Tutorial > What are the effects of using multiple IDs on the same page_Experience exchange

What are the effects of using multiple IDs on the same page_Experience exchange

WBOY
Release: 2016-05-16 12:10:15
Original
1736 people have browsed it

When defining a style in the style sheet, you can define an id or a class, for example:

ID method: #test{color:#333333}, call

content
CLASS method: .test{color:#333333}, call
content
in the page.
id can only be used once on a page, and class can be referenced multiple times.

Some netizens asked, there seems to be no difference between id and class. I used multiple ids on the page and it was displayed normally in IE. What is the impact of using multiple ids?

Answer: The first impact is that it cannot pass W3 verification.

In terms of page display, current browsers still allow you to make this mistake, and using multiple identical IDs can "generally" display normally. But when you need to use JavaScript to control this div through id, an error will occur.

id is a tag used to distinguish different structures and contents, just like your name. If there are two people with the same name in a room, confusion will occur;
class is a style that can be applied to In terms of any structure and content, it is like a piece of clothing;
Conceptually speaking, it is different:
id finds the structure/content first, and then defines a style for it; class defines a style first, and then Set for multiple structures/contents.

Web standards hope that everyone uses strict habits to write code,

For example: you can use
to display bold, or you can use to display , but W3C recommends that you use because is more semantic
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template