Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use id selector in css

Shulou Source: shulou.com Published: 2022-06-01 13:09:57 10月02日 Update

This article will explain in detail how to use the id selector in css. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Id selector

The id selector is identified by #, followed by the id name

The basic syntax is as follows:

Id selector description:

# id {attribute 1: attribute value 1; attribute 2: attribute value 2; attribute 3: attribute value 3;}

The id value of an element is unique and can only correspond to a specific element in the document.

The usage of id selector is similar to that of class selector

The difference between id selector and class selector

Id objects with the same name are not allowed on the same page. But class with the same name is allowed

The class selector class is like a person's name and can be reused many times.

Id selector id is like a person's ID card number, unique in the country, can not be reused, can only be used once.

The biggest difference between an id selector and a class selector is the number of times it is used.

Summary:

Class selection is used most often in our modified style.

Id selectors are generally used on elements that are unique to the page and are often used in conjunction with javascript.

Div {font-size: 20px;} # id1 {color: red;} # id2 {color: green } # id3 {color: # 800080;} # id4 {color: # 0000FF Wun Xi Sha [Qing] Naran Xingde has fallen into the world over the past 18 years, blowing flowers and chewing stamens to make ice strings, affectionately sent to that side? Purple jade hairpin oblique light back, red pink cold pillow letter edge. Looking at the advantages, but speechless. This is the end of this article on "how to use id selectors in css". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Selection attribute element name article same more page different good practical worldly national content number uniqueness affectionate benefit object over the years Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia vpn MariaDB Redmi Shulou Technology