Home > Web Front-end > HTML Tutorial > What is the difference between class and id

What is the difference between class and id

php中世界最好的语言
Release: 2017-11-22 16:17:48
Original
5920 people have browsed it

What is the difference between

id and class? What does ID mean? What does class mean? Today we will introduce to you these two easily confused concepts

You can see the use of id and class in div, span, p tags, h1, h2 and other tags. id and class are very commonly used tagsAttributes.

<div id="header"></div> 
<div class="menu"></div>
Copy after login

The above is what we often see id and class existing in div tags. "Header" and "menu" are custom CSS names. (Pay attention to the case of CSS naming, and do not name css starting with a number)

Explanation on the usage of id and class

1. Differences in usage

id is unique, in a web page The same name can only be used once; a class named

class can be used countless times in a web page.

2. Difference in css

id in css code is a class named starting with "#" pound sign

class is named in css code starting with "." Class names starting with a lowercase period symbol

What do id and class mean?

Both id and class can be used in any tag on the web page. Generally, IDs are used for more important parts and special boxes, while classes are used for small parts that are not important or small structures. id calls the style selector named with the "#" pound sign in CSS, and class calls the style selector named with "." English half-width lowercase period in CSS.

I believe that through this article everyone should have a deep impression of their differences. For more exciting content, please pay attention to php Chinese website Other related articles!

Related reading:

What is pseudo-static


How to view the web page source code of html


HTML5 text barrage effect

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

Related labels:
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