Home > Article > Web Front-end > What does id mean in css?
id represents the ID selector in CSS. The ID selector allows the style to be specified in a manner independent of the document element; the HTML element uses the id attribute to set the id selector, while the id selector in CSS Devices are defined with "#", also known as checkerboard numbers or pound signs.
Recommended: "css video tutorial"
CSS ID Selector
In some ways, ID selectors are similar to class selectors, but there are some important differences.
Syntax
The HTML element uses the id attribute to set the id selector, and the id selector in CSS is defined with "#" - also known as the checkerboard number or pound sign .
Please see the following rules:
*#intro {font-weight:bold;}
Like class selectors, wildcard selectors can be ignored in ID selectors. The previous example could also be written as:
#intro {font-weight:bold;}
The effect of this selector would be the same.
The second difference is that the ID selector does not refer to the value of the class attribute. There is no doubt that it refers to the value in the id attribute.
Usage:
html <div class="to"> <p id="dog">指定具有id元素的样式</p> </div> css #dog{ background-color: aqua; }
Case Sensitive
Please note that class selectors and ID selectors may be case sensitive. This depends on the language of the document. HTML and XHTML define class and ID values as case-sensitive, so the case of class and ID values must match the corresponding values in the document.
Therefore, for the following CSS and HTML, the element will not be made bold:
#intro {font-weight:bold;} <p id="Intro">This is a paragraph of introduction.</p>
The selector will not match the above element due to the different case of the letter i.
The above is the detailed content of What does id mean in css?. For more information, please follow other related articles on the PHP Chinese website!