Hello I have a problem in hover !! I write small code to test "hover" But unfortunately this code does not work correctly. Please guide me what is problem of bellow codes? Thank you. <!doctype html> <html> <head> <style> p{display:none;} a:hover p{display:block;} </style> </head> <body> <a href="#">Home</a> <p class="test3">This is my test </p> </body> </html>
As @kk5st said, it's a sibling, not a child of it. Whilst technically HTML 5 says you could just make the anchor wrap the paragraph, I've found that to be unreliable in practice, you'd ALMOST think that would be invalid HTML in all prior specifications or something. OH WAIT, IT WAS! The "+" adjacent sibling selector should do the job: a:hover+p {display:block;} In modern browsers -- that's the rub. Anything earlier than IE7 wont' support it; but really most people have dropped supporting IE6 or earlier so you should be fine on that count.