I have a list like this and I want it to change the font-weight to bold of the list item which I was hovering but instead of that it applies the changes for the whole list of all lists of my document (depends on my attempts)
li:hover {
cursor: pointer;
font-weight: bold;
}
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="2.css">
</head>
<body>
<ul class="tree" id="tree">
<li>Animals
<ul>
<li>Mammals
<ul>
<li>Cows</li>
<li>Donkeys</li>
<li>Dogs</li>
<li>Tigers</li>
</ul>
</li>
<li>Other
<ul>
<li>Snakes</li>
<li>Birds</li>
<li>Lizards</li>
</ul>
</li>
</ul>
</li>
<li>Fishes
<ul>
<li>Aquarium
<ul>
<li>Guppy</li>
<li>Angelfish</li>
</ul>
</li>
<li>Sea
<ul>
<li>Sea trout</li>
</ul>
</li>
</ul>
</li>
</ul>
</body>
</html>
I want to know is there a way to do it without adding IDs or classes to the elements.
And I want it to do in a dynamic way.
If there's a way to do it with JS it will be great too.