Is there a way in CSS to apply the hover state to one part of HTML text when another part is hovered over, both sharing the same class?
I have a block of text in HTML that is broken down into individual words, each word linked to a specific CSS class. It is possible for multiple words to be linked to the same class.
For example, if I have three words and two classes (classA, classB),
word1, word3 -> classA
word2 -> classB
This would result in the following HTML code :
<span class=classA>word1</span>
<span class=classB>word2</span>
<span class=classA>word3</span>
The issue at hand is changing the appearance of all words with a shared class when any one of them is hovered over.
I attempted the following:
.classA {
color: red;
}
.classA:hover {
color: blue;
}
Unfortunately, when the mouse hovers over "word1," only "word1" is highlighted, and not "word3" which belongs to the same class ("classA").
Any assistance on this matter would be greatly appreciated!