国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

The difference between CSS id selector and class selector

The previous section introduced several basic selectors. This section shares the difference between id and class.

The id and class attributes are two common attributes in web pages. They work together to make The entire page becomes colorful. When we define a style for an element. You can use id or class. But we should also pay attention to the difference between the two.

1. When writing in a CSS style sheet, the prefix symbol ‘#’ should be added in front of the id selector, and the prefix symbol ‘.’ should be added in front of the class selector.

2. The id attribute can generally only be used once in a page, while the class can be referenced multiple times.

3. ID is used as a tag of an element to distinguish different structures and contents, while class is a style that can be applied to any structure and content.

4. In terms of layout ideas, we generally adhere to this principle: id determines the structure and content of the page first, and then defines the style for it: on the contrary, class defines a type of style first, and then Apply class styles to different elements and content on the page as needed.

5. Currently, browsers allow multiple IDs with the same attribute value to appear on the same page. Under normal circumstances, they can be displayed normally. However, when using JavaScript to control elements through IDs, errors will occur. .

6. In actual application, class is more used in text sections and page modifications, while id is more used to implement grand layouts and design containing blocks or containing box styles.

Note:

ID has the characteristics of high priority and uniqueness. Refers to "individual".
Compared to ID, the priority of class is relatively moderate, specifically referring to "specific groups".
The use of Class requires reference to object-oriented abstract concepts and abstracting common attributes.

ID is to find the structure/content first, and then define the style for it;
Class is to define a style first, and then apply it to multiple structures/content.



Continuing Learning
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>id和class</title> <style> /*id選擇器*/ #rrrrr { background-color: red; } /*類選擇器*/ .important { color: aqua; font-size:smaller; } /*類選擇器*/ .important2222 { font-size:larger; background-color:black; } </style> </head> <body> <!--可以同時使用多個類--> <div class="important important2222"> 1、人生最精彩的不是成功的那一瞬間,而是回頭看,那段漆黑看似沒有盡頭、苦苦摸索的過程。其實(shí),我只是很在意,在意在我所在意的人的心里,我,在哪個位置。 </div> <h1> 1、人生最精彩的不是成功的那一瞬間,而是<span>3333333333</span> </h1> <p> 2、生活再不如人意,都要學(xué)會自我溫暖和慰藉,<br /> 給自己多一點(diǎn)欣賞和鼓勵。生活就是童話,<br /> 只要心存美好,結(jié)局就會是美好。<br /> </p> <p id="rrrrr"> 3、旁觀者的姓名永遠(yuǎn)爬不到比賽的計分板上。 </p> <p> 4、強(qiáng)烈的信仰會贏取堅強(qiáng)的人,然后又使他們更堅強(qiáng)。 </p> <p> 5、只要我們能夢想的,我們就能實(shí)現(xiàn)。 </p> <p> 6、每一個成功者都有一個開始。勇于開始,才能找到成功的路。 </p> </body> </html>
submitReset Code