Skip to main content

Attribute selectors

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Attribute Selector Example</title>
  <style>
    a {
      text-decoration: none;
      color: blue;
    }

    a[target="_blank"] {
      color: green;
      font-weight: bold;
      text-decoration: underline;
    }
  </style>
</head>

<body>
  <h1>Attribute Selector Example</h1>
  <p>Here are some links:</p>
  <ul>
    <li><a href="https://www.example.com" target="_blank">Example Link (opens in new tab)</a></li>
    <li><a href="https://www.example.com">Example Link (opens in same tab)</a></li>
    <li><a href="https://www.example.com" target="_self">Example Link (opens in same tab)</a></li>
    <li><a href="https://www.example.com" target="_blank">Another Link (opens in new tab)</a></li>
  </ul>
</body>

</html>

You can view it live here.