Search notes:

CSS pseudo class selector: target

The pseudo class selector :target selects the HTML element with the attribute id that is the currently selected target of a <a href="…#tgt"> link.
<!DOCTYPE html>
<html>
<head>
  <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
  <title>CSS - :target pseudo class</title>

  <style>
    :target {
       background-color: navajowhite;
    }
  </style>

</head>
<body>


  <p>This paragraph has no id.</p>
  <p id='x'>This paragraph has has id=x and a <a href='#z'>link to z</a>.</p>
  <p id='y'>This paragraph has has id=y.</p>
  <p>This paragraph has no id and a <a href='#y'>link to y</a>.</p>
  <p id='z'>This paragraph has has id=z</p>

</body>
</html>
Github repository about-css, path: /selectors/pseudo-classes/target.html

See also

CSS selectors

Index