#Syllabus a
is a descendant selector. That means the rule is applied to all anchors that are descendant of #Syllabus.
Using a child selector would select only anchors that are direct children of #Syllabus: #Syllabus > a
.
#Syllabus > a {
position: absolute;
top: 0px;
left: 130px;
width: 112px;
height: 40px;
background-image: url(/Assets/Syb_but.png);
background-repeat: no-repeat;
}
#Syllabus > a:hover {
background-image: url(/Assets/QuesPap_but_ul.png);
}
.ul_menu {
position: relative;
top: 44px;
left: 43px;
display: none;
}
ul, li {
margin: auto;
padding: 0;
}
manpreet
Best Answer
2 years ago
Here's my HTML structure:
And here's my CSS:
When I view this code in any browser, the
background-image: url(/Assets/Syb_but.png);
is generated everytime by thetag. That is, the
sym_but.png
appears on the right oflinkhref="https://forum.tuteehub.com/tag/1">1
andlink2
along with the initial one.