How i can do this in CSS? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How i can do this in CSS?

I have created this code. I want that when the user hover on div which has an id x then the colour of the p tag changed to blue. how i can do this with only CSS and HTML without javascript. https://code.sololearn.com/WGKImQSMI7wq/?ref=app

12th Mar 2020, 2:12 AM
Maninder $ingh
Maninder $ingh - avatar
16 Answers
+ 8
https://code.sololearn.com/W6fHo8Miy8J4/?ref=app This (+)selector only works if the p is immediately after the #x(div) tag in the example.
12th Mar 2020, 2:34 AM
Jaydeep Khatri
Jaydeep Khatri - avatar
+ 4
Hello, Hereโ€™s a help... I changed a bit of your code. Feel free to change the code. https://code.sololearn.com/WWrn4zDWA4TT/?ref=app
12th Mar 2020, 2:25 AM
JTLZ
+ 4
What about now?
12th Mar 2020, 2:29 AM
JTLZ
+ 4
Nice... Itโ€™s all yours :) #HappyCoding
12th Mar 2020, 2:30 AM
JTLZ
+ 4
JTLZ what ,no let i have two div which one has an id x and another one has an id y.if i hover on x id div then the background colour of div whose id y changed. But the condition is that no anyone is inside them.
12th Mar 2020, 2:34 AM
Maninder $ingh
Maninder $ingh - avatar
+ 4
Nope we are diffrent WhyFry lol
12th Mar 2020, 10:46 AM
JTLZ
+ 4
WhyFry Why do I want two accounts lol ๐Ÿ˜‚. I am just helping Maninder $ingh Then it came to me that question โ€œhover Cssโ€ so i asked it with the code I created to help Maninder
12th Mar 2020, 10:56 AM
JTLZ
+ 3
https://code.sololearn.com/Wayn2N88u1eW/?ref=app I didn't know what you mean because :hover is only for link tags that changes color when you put the cursor on it.. But here, I created an animation that changes color of your tag... Edit : also I forgot to remove your comment
13th Mar 2020, 9:29 AM
Mark๐Ÿ‘จโ€๐Ÿ’ป
Mark๐Ÿ‘จโ€๐Ÿ’ป - avatar
+ 2
JTLZ i know this but if my p tag is not inside the div tag then how i can do this.
12th Mar 2020, 2:28 AM
Maninder $ingh
Maninder $ingh - avatar
+ 2
JTLZ it worked.
12th Mar 2020, 2:30 AM
Maninder $ingh
Maninder $ingh - avatar
+ 2
Jaydeep Khatri thanks what is the use of + is here.
12th Mar 2020, 2:36 AM
Maninder $ingh
Maninder $ingh - avatar
+ 2
WhyFry no we are different.LOL๐Ÿ˜†๐Ÿ˜…๐Ÿคฃ๐Ÿคฃ๐Ÿคฃ๐Ÿ˜…even i don't know who is JTLZ
12th Mar 2020, 9:51 AM
Maninder $ingh
Maninder $ingh - avatar
+ 2
WhyFry looks like a computer bot.๐Ÿ˜…๐Ÿคฃ๐Ÿคฃ I'm just kidding. JTLZ [#NeverGiveUp!] He just kidding i think.
12th Mar 2020, 11:07 AM
Maninder $ingh
Maninder $ingh - avatar
0
put your text in div and set color in hover blue
13th Mar 2020, 12:03 PM
Sobhan Esfandiary
Sobhan Esfandiary - avatar
0
It' good and easy
13th Mar 2020, 4:24 PM
โ€Žุฎู†ุทูŠุท ุตููˆุงู† ุฃู…ูŠู†โ€Ž
โ€Žุฎู†ุทูŠุท ุตููˆุงู† ุฃู…ูŠู†โ€Ž - avatar
0
past your text in the div#x element and asign the color you want in your style sheet! in your code you have pasted the text in a paragraph who doesn't have id x, this is the reason why your code doesn't work!
13th Mar 2020, 5:50 PM
pnembot
pnembot - avatar