2018-10-12 19:37:13 +00:00
|
|
|
---
|
|
|
|
title: Class Equals
|
|
|
|
---
|
|
|
|
## Class Equals
|
2018-11-04 00:33:22 +00:00
|
|
|
To select an item with a class attribute, you use the following selector:
|
2018-10-12 19:37:13 +00:00
|
|
|
|
2018-11-04 00:33:22 +00:00
|
|
|
```css
|
|
|
|
p[class="happy"] {
|
|
|
|
color: yellow;
|
|
|
|
}
|
|
|
|
```
|
2018-10-12 19:37:13 +00:00
|
|
|
|
2018-11-04 00:33:22 +00:00
|
|
|
This selector is not commonly used, as there is a general class selector. We can rewrite the above selector like this:
|
2018-10-12 19:37:13 +00:00
|
|
|
|
2018-11-04 00:33:22 +00:00
|
|
|
```css
|
|
|
|
p.happy {
|
|
|
|
color: yellow;
|
|
|
|
}
|
|
|
|
```
|
2018-10-12 19:37:13 +00:00
|
|
|
|
|
|
|
#### More Information:
|
2018-11-04 00:33:22 +00:00
|
|
|
https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors
|