CSS Navigation pseudoclasses - Part 2

Notes:

CSS - Pseudo Class Selectors (Navigation) - Part 2

4.
selector : target
{
declaration list;
}

It selects any html element targeted by the selector, if its status is targeted
(only when element id or name appears as targeted fragment identifier in the page URI.)

Ex:
p:target
{
border : 2px dotted red;
}
It selects any p element which is currently a targeted fragment identifier in the page URI (Uniform Resource Identifier).

Example Code:

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Attribute selectors demo</title>
<style type="text/css">
p:target
{
border:2px solid red;
}
</style>
</head>
<body>
<p id="top">Top section</p>
<a href="#bottom">Bottom section</a>
<br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/>

<p id="bottom">Bottom section</p>
<a href="#top">Top section</a>

<br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/>
</body>

</html>

Interview Questions: