Skip to content

Instantly share code, notes, and snippets.

@nocodesupplyco
Last active December 19, 2022 20:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save nocodesupplyco/afb8a13c3ae3774514133b23fc16b5ad to your computer and use it in GitHub Desktop.
CSS Target Attribute
/* Select elements with a specified attribute and value. */
a[target="_blank"] {
color: red;
}
/* Select elements with an attribute value containing a specified WORD. */
svg[title~="flower"] {
border: 5px solid yellow;
}
/* Select elements with the specified attribute, whose value can be exactly the specified value, or the specified value followed by a hyphen (-). */
h2[class|="top"] {
background: yellow;
}
/* Select elements with the specified attribute, whose value STARTS with the specified value. */
[class^="top"] {
background: yellow;
}
/* Select elements whose attribute value ENDS with a specified value. */
[class$="test"] {
background: yellow;
}
/* Select elements whose attribute value contains a specified value, which does NOT have to be a whole word. */
[class*="te"] {
background: yellow;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment