#id selector in CSS

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.

I like to hear from you about this !!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.