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

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759406252, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/web/CSS/selectors/pseudo-classes/target(67): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78