How to write a:hover in inline CSS? - GeeksforGeeks

30 Jul, 2021
It is called pseudo-selector and used to select all the elements when the user move mouse over the elements. It can be used on all the element. A <!DOCTYPE html> element must be declared in the document to see the working of this selector in all the elements.
Example 1:
<!DOCTYPE html><html>    <head>        <title>a:hover in inline CSS</title>        <style>            h1 {                color:green;            }            body {                text-align:center;            }            a {                text-decoration:none;                color:green;            }        </style>    </head>    <body>        <h1>GeeksforGeeks</h1>        <h2>a:hover in inline CSS</h2>        <a href="#" onMouseOver="this.style.color='red'"        onMouseOut="this.style.color='green'" >GeeksforGeeks</a>    </body></html>                    
Output:
Example 2: This example uses JavaScript to display a:hover content in CSS. The onmouseover and onmouseout event attribute is called to display the a:hover content.
<!DOCTYPE html><html>    <head>        <title>a:hover in inline CSS</title>        <style>            h1 {                color:green;            }            body {                text-align:center;            }            a {                text-decoration:none;                color:green;            }        </style>        <script>            function mouseover() {                document.getElementById("gfg").style.color = "red";            }                          function mouseout() {                document.getElementById("gfg").style.color = "green";            }        </script>    </head>    <body>        <h1>GeeksforGeeks</h1>        <h2>a:hover in inline CSS</h2>        <a href = "#" id="gfg" onmouseover="mouseover()"         onmouseout="mouseout()">GeeksforGeeks</a>    </body></html>                    
Output:
Supported Browsers: The browser supported by a:hover selector are listed below:
Apple Safari 3.1
Google Chrome 4.0
Firefox 2.0
Opera 9.6
Internet Explorer 7.0
HTML is the foundation of webpages, is used for webpage development by structuring websites and web apps.You can learn HTML from the ground up by following this HTML Tutorial and HTML Examples.
CSS is the foundation of webpages, is used for webpage development by styling websites and web apps.You can learn CSS from the ground up by following this CSS Tutorial and CSS Examples.
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Misc
Picked
CSS
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to update Node.js and NPM to next version ?
How to create footer to stay at the bottom of a Web page?
How to apply style to parent if it has child with CSS?
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to update Node.js and NPM to next version ?
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property