freeCodeCamp/guide/english/css/selectors/attribute/class-equals/index.md

23 lines
426 B
Markdown
Raw Normal View History

2018-10-12 19:37:13 +00:00
---
title: Class Equals
---
## Class Equals
To select an item with a class attribute, you use the following selector:
2018-10-12 19:37:13 +00:00
```css
p[class="happy"] {
color: yellow;
}
```
2018-10-12 19:37:13 +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
```css
p.happy {
color: yellow;
}
```
2018-10-12 19:37:13 +00:00
#### More Information:
https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors