#id selector in CSS
Milap Patel
Technical Manager | Node.js | React | JavaScript | AWS Certified Cloud Practitioner | PHP | WordPress | Front-end | MongoDB | MySQL
The #id selector allows you to target an element by referencing the id HTML attribute.
ID attribute values should be unique. HTML with two or more identical ids does not validate, and will produce unpredictable results.
If there are two of the same, CSS will still match and style both. JavaScript however, when querying for an ID, will find the first and stop.
ID selectors are extremely powerful. They have a very high specificity.
A valid #id cannot start with a number and must be at least one character long. id attributes and selectors are case-sensitive, and must exactly match across HTML, CSS and JavaScript.