css syntax a:hover on element inside id and class
I want to apply same style to
a, a:hover
of elements residing inside an id, class and element. What's the most valid and effective syntax?
Example:
#leftmenu .shortcuts ul li a, a:hover {
text-decoration: none;
}
开发者_开发知识库
Regards, //t
CSS isn't that smart, so you'll have to explicitly write out that first part, again. As @sdleihssirhc
noted, you can omit li
, as ul
elements are assumed to already contain li
s, so the selector would still work:
#leftmenu .shortcuts ul a,
#leftmenu .shortcuts ul a:hover {
text-decoration: none;
}
I'd consider giving that ul
an id
, as it would condense your CSS considerably:
#lm_ul a, #lm_ul a:hover {
text-decoration: none;
}
or you could just do something similar to apply to all links inside a container with an id="leftMenu"
CSS:
#leftMenu > * a, #leftMenu > * a:hover{ .... }
HTML:
<ul>
<li><span><a>item1</a></span></li>
<li><p><a>item1</a></p></li>
<li><div><a>item1</a></div></li>
<li><em><a>item1</a></em></li>
</ul>
This will take into account every element a no matter what is wrapping the links inside the container with id="leftMenu"
精彩评论