HTML+CSS Easy to Get Started with ID Selector
In some ways, ID selectors are similar to class selectors, but there are some important differences
Syntax:
# id name{
Style
}
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 ??to be case-sensitive, so the case of class and ID values ??must match the corresponding values ??in the document
Example:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>ID選擇器</title> <style type="text/css"> #div{ color:green; font-family:隸書; font-size:18px; } </style> </head> <body> <div id="div">中華民族偉大復(fù)興!</div> </body> </html>
id selectors and classes What is the difference between selectors
Unlike classes, ID selectors will be used once and only once in an HTML document.
Unlike class selectors, ID selectors cannot be used together because the ID attribute does not allow a space-separated list of words.
For example: <div class ="class1 class2 class2"></div>That is to say, class can be equal to a list of multiple classes
Write id = "div1 div2", that is, there can only be one id, not like the class attribute