Why use an attribute selector to match classes?
The []
syntax is an attribute selector.
a[class="btn"]
This will select any <a>
tag with class="btn"
. However, it will not select <a>
which has class="btn btn_red"
, for example (whereas a.btn
would). It only exactly matches that attribute.
You may want to read The 30 CSS Selectors you Must Memorize. It's invaluable to any up-and-coming web developer.