Files
freeCodeCamp/guide/english/css/selectors/attribute/class-equals/index.md
CGS-Jack-Bashford d36806a06d Add example and reason why is not commonly used (#20837)
* Add example and reason why is not commonly used

Expanded from stub - added an example, an example of the simplified version (.class selector) and added some external references

* removed w3schools links
2018-11-03 17:33:22 -07:00

426 B

title
title
Class Equals

Class Equals

To select an item with a class attribute, you use the following selector:

p[class="happy"] {
    color: yellow;
}

This selector is not commonly used, as there is a general class selector. We can rewrite the above selector like this:

p.happy {
    color: yellow;
}

More Information:

https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors