CSS Attribute Selectors

  • You can target elements by whether or not they have specific attributes or whether those attributes have certain values.
  • We can also do some pattern matching on the attribute values.
  • We use square brackets to contain the attribute names and/or values
p[title]{
    /* target paragraphs that has a title attribute */
}
a[href="#"]{
    /* targets anchors that have an href whose value is "#" exactly */
}
img[src^="https://"]{
    /* targets images whose src attribute starts with "https://"
}
Last Updated: : 8/26/2019, 2:39:05 PM