Home  >  Article  >  Web Front-end  >  What does class mean? What is the difference between id and class?

What does class mean? What is the difference between id and class?

云罗郡主
云罗郡主Original
2018-10-31 16:45:3714203browse

Many novices have just come into contact with HTML and are not very clear about what class means. However, some novices are still unclear about id and class. Let's summarize what class means? What is the difference between di and class?

What does class mean? What is the difference between id and class?

#1: What does class mean? What does id mean

In HTML, class is the class name used to specify elements. Currently, class is used for classes in style sheets. Some experts will also use js to set specified elements. , in css style, use dots to set attributes. In the same HTML, we can use the same class many times.

id means the only id in html, symbolizing the identity of this tag. Many times, we will use id in js. If js wants to modify a tag attribute, js will use id to set it. It is the only attribute. If there are two identical ids, then the js special effects will not know which id to change based on. [Recommended reading: How to use the class attribute in JS]

2: Syntax for using id and class

<div id="a"></div>
rrree

where a and b are Custom naming

3: What is the difference between id and class

1. Differences used in css styles

In css, id It is unique. In a piece of HTML, the same name can only be used once. Class is exactly the opposite of id. It can be used many times in a page. ID can be used to identify one element, while class can be used to identify multiple elements.

2. Difference in naming methods

Class is named with the "#" key in css, while id is named with "."

Currently both class and id are It can be used on web pages, but id will be used outside the box. If it is a small layout that is not important, we can use class.

The above is a complete introduction to what does class mean? What is the difference between id and class? If you want to know more about html tutorial, please pay attention to the php Chinese website.


The above is the detailed content of What does class mean? What is the difference between id and class?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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