HTML CSS examples for CSS Selector:active
The :active selector selects the active element. An element is active when you click on it.
The :active selector can be used on all elements, not only links.
Use the :link selector to select links to unvisited pages.
Use the :visited selector to select links to visited pages.
Use the :hover selector to select links when you mouse is over them.
:active must come after :hover if present in the CSS definition.
Select and style a <p>, <h1> and <a> element when you click on it:
Click on the paragraphs, headers, and links to see what is getting a style.
<!DOCTYPE html> <html> <head> <style> p:active, h1:active, a:active{ background-color: yellow; } </style><!-- w w w .jav a 2 s .c o m--> </head> <body> <h1>Welcome to My Homepage</h1> <div class="intro"> <h2 id="myId">this is a test</h2> <p id="myElement">this is a paragraph</p> <p>I <b>like</b> css</p> </div> <h2>Links:</h2> <p>Here are my favorite websites:</p> <a href="https://www.java2s.com">java2s.com</a> <a href="http://www.google.com" target="_blank">google.com</a> <a href="http://www.wikipedia.org" target="_top">wikipedia.org</a> </body> </html>