h2:target {
outline: 2px solid;
}Using the :target pseudo-class in selectors / notebook
Using the :target pseudo-class in selectors
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
#reference:target {
background-color: yellow;
}:target {
color: red;
}<h4 id="one">…</h4>
<p id="two">…</p>
<div id="three">…</div>
<a id="four">…</a> <em id="five">…</em>
<a href="#one">First</a>
<a href="#two">Second</a>
<a href="#three">Third</a>
<a href="#four">Fourth</a>
<a href="#five">Fifth</a>