How to write a:hover in inline CSS?
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
Recommended Posts:
- How to write an inline IF statement in JavaScript ?
- What is the difference between inline-flex and inline-block in CSS?
- What is the difference between display: inline and display: inline-block in CSS?
- Kotlin Inline classes
- What is the inline function in JavaScript ?
- How does inline JavaScript work with HTML ?
- Type Aliases vs Inline Classes
- HTML | Block and Inline Elements
- How to remove the space between inline-block elements?
- How to remove all inline styles using JavaScript/jQuery ?
- Displaying inline and multiline blocks of code using Bootstrap
- How to stop event propagation with inline onclick attribute in JavaScript ?
- Why is Java 'write once and run anywhere'?
- CSS | :read-write Selector
- HTML | DOM write() Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


