I am new to the web and I don’t quite understand when I see this way of writing. Doesn’t it mean that the id is unique in a document? Then the way of writing div#xxxx means that the div element with the id of xxxx is not unique. Sorry, does the previous div seem redundant?
The id is unique. The previous div can be omitted, but it will not go wrong if it is written. Sometimes for the sake of code For readability, it is recommended to write
div#box {
color: red;
}
==>
Elements that satisfy this selector:
1. DIV element
2. ID is "box"
Of course, if there is another selector for #box { color: blue; }
div#box { color: red; }'s weight (priority) ratio is #box { color: blue; }
, then the final content color of div is "red"
Thank you both, I understand!