-
-
Notifications
You must be signed in to change notification settings - Fork 218
Levels of specificity for selection of elements
ankit edited this page Sep 14, 2010
·
1 revision
Low:
Returns tag name of element.
Medium:
- If an element has a class,
tag.class
is returned.
- If a element doesn’t have a class, but has an ID,
#id
is returned.
- If none of the above, the above two steps are applied to the parent of the element. This maybe done upto 2 times.
The selector then becomes:parent-selector child-selector
High:
- If element has an ID,
#id
is returned.
- If element has a class, its selector becomes
tag.class
and these two steps are applied to its parent. This is done only one time.
The selector then becomes:parent-selector child-selector