CSS ATTR SELECTORS

rainbow baker

 CSS ATTR SELECTORS

  • The [attribute] selector is used to select elements with a specified attribute.
  • The [attribute^="value"] selector is used to select elements with the specified attribute, whose value starts with the specified value.
  • The [attribute$="value"] selector is used to select elements whose attribute value ends with a specified value.

EXAMPLE

<!DOCTYPE html>
<html>
<head>
<style>
a[target] {
background-color: yellow;
}
</style>
</head>
<body>
<h2>CSS [attribute] Selector</h2>
<p>The links with a target attribute gets a yellow background:</p>
<a href="https://www.w3schools.com">w3schools.com</a>
<a href="http://www.disney.com" target="_blank">disney.com</a>
<a href="http://www.wikipedia.org" target="_top">wikipedia.org</a>
</body>
</html>

OUTPUT



Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send