August 21, 2012
How to style <ul> and <li> without affecting MENU
Question by dotman14
How can I apply a different styles to the same elements at different parts of my HTML/CSS.
I have tried the following it doesn’t seem to work.
MENU
<div class="menu">
<ul>
<li><a href="#"><Link 1</a></li>
<li><a href="#"><Link 1</a></li>
<li><a href="#"><Link 1</a></li>
</ul>
</div>
somewhere in the webpage
<div class="others">
<ul>
<li><a href="#"><Link 1</a></li>
<li><a href="#"><Link 1</a></li>
<li><a href="#"><Link 1</a></li>
</ul>
</div>
CSS
.menu ul,li{
color: rgb(242,253,255);
list-style: none;
text-decoration: none;
font-size: 20px;
font-family: chaparral pro;
}
.others ul,li{
color: rgb(242,253,255);
list-style: none;
text-decoration: none;
font-size: 10px;
font-family: chaparral pro;
}
Answer by Starx
You made a tiny mistake you generalized style of li
in the following part.
.others ul,li { ..... }
The above will apply to ul
inside .others
and all the li
through out the page. Just use
.others ul, .others li {
/*.....*/
}