html - CSS priorities and targeting specific elements -


my question should pretty strait forward. reason can't wrap head around today.

i'm making menu structure so

<div class="wrapper">     <ul>         <li class="menu-item"><a href="#">menu item</a>             <div class="inner">                 <a href="#">login</a>              </div>         </li>     </ul> </div> 

i trying target login link using following css selector:

.inner a{} 

the selector working, following selector taking css presidence, , overriding above selector:

li.menu-item a{} 

i'm totally baffled. why second selector take style preference on first? how guys recommend target above "a" elements?

why second selector take style preference on first?

because second selector more specific first. first contains one class , one type selector while second has one class , two type selectors.

to calculate specificity, think of selector consiting of 4 numbers, starting @ (0,0,0,0)

also:


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -