Β· 1 min read

CSS attribute selectors

Target all images that have an empty alt tag

img[alt=""] {
  /* Rules for <img> elements without alt text. */
}
a:not([href]) {
  /* Rules for <a> elements without a href attribute. */
}

Bonus - Target pseudo selector

For highlighting hash (#) links when they’re active in the current URL fragment.

h1:target {
  /* Rules for h1 elements matching the current URL fragment. */
}

Tag icon Post tagged with:
#css