URLs with an # followed by an anchor name link to a certain element within a document. The element being linked to is the target element.
The :target selector can be used to style the current active target element.
Code:-
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
:target {
background: yellow;
border: 1px solid red;
}
</style>
</head>
<body>
<a href="#a">Go to Div A</a>
<br>
<a href="#b">Go to Div B</a>
<br>
<div id="a">Tab 1</div>
<div id="b">Tab 2</div>
</body>
</html>
Css:- target
Reviewed by Network security
on
May 13, 2019
Rating:
No comments: