Add explanation for selected elements (#28044)
This commit is contained in:
committed by
Randell Dawson
parent
11e8758d07
commit
e0035a44a9
@ -13,9 +13,9 @@ To select an element with a specific ID, write a hash (#) character, followed by
|
|||||||
```
|
```
|
||||||
You can combine the ID selector with other types of selectors to style a very specific element.
|
You can combine the ID selector with other types of selectors to style a very specific element.
|
||||||
```css
|
```css
|
||||||
section#about:hover { color: blue; }
|
section#about:hover { color: blue; } /* applies style to hover state of section element with an ID of 'about' */
|
||||||
|
|
||||||
div.classname#specified_id { color: green; }
|
div.classname#specified_id { color: green; } /* applies style to a div element with a class name of 'classname' and an ID of 'specified_id' */
|
||||||
```
|
```
|
||||||
### Note about IDs
|
### Note about IDs
|
||||||
ID should be avoided when styling if possible. As it has high specificity and it can be overriden only if you use inline styles, or add styles into ```<style>``` tags in the HTML. The weight of IDs override class selectors and type selectors.
|
ID should be avoided when styling if possible. As it has high specificity and it can be overriden only if you use inline styles, or add styles into ```<style>``` tags in the HTML. The weight of IDs override class selectors and type selectors.
|
||||||
|
Reference in New Issue
Block a user