Solution 1 :

You could try to specify further your accessor:

.change-style a {
   font-family: serif;
}

Or you can use !important to force a style to override other styling:

.change-style a {
   font-family: serif !important;
}

Solution 2 :

.change-style + a {
font-family: serif !important;
}

Or

.dropdown-menu.change-style a {
font-family: serif !important;
 }

Or

.dropdown-menu.change-style + a {
font-family: serif !important;
}

Or

.dropdown-menu a  {
font-family: serif !important;
} 

Or

.dropdown-menu + a  {
 font-family: serif !important;
 }

Or

.change-style a  {
 font-family: serif !important;
 }

Or specificity >

.dropdown-menu>.change-style a {
 font-family: serif !important;
 }

But you’ll need to specify in your head, either through stylesheet or @import see https://fonts.google.com/specimen/Roboto?selection.family=Roboto:[email protected] for example or here How to import Google Web Font in CSS file? or here https://www.w3schools.com/css/css3_fonts.asp

Also, make sure your CSS is correct. You may not be specifying exactly what you want:

For example:

font-family: 'PT Serif', serif;

May be closer if you’re using Google Fonts.

Problem :

I need to change the style of the items in a dropdown, however I don’t know how to reach to the specific item:

this is my code:

<li class="nav-item dropdown">
    <a class="nav-link menu-icon dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
      <span class="navbar-toggler-icon"></span>
    </a>                             
     
    <div class="dropdown-menu change-style">
      <div class="nav-to-one" >
          <a class="dropdown-item font-weight-bold" href="#">Test</a>
          <hr class="card-meta-divider m-2">
          
      </div>
    </div>  
</li>

and I need to change change-style:

.change-style {
   font-family:serif;
}

It does not work in this way!

Comments

Comment posted by CSS specificity

Your class selector

Comment posted by stealththeninja

Check developer tools, see if your

Comment posted by Rickard Elimää

Have you tried applying anything else, like

Comment posted by ElisaFo

Thanks, I tried your solution but does not change anything!

Comment posted by minimal complete example

@ElisaFo I suspect your question may be incomplete. There’s an option to include a working code sample. Can you demonstrate your issue with a

Comment posted by Adriaan De Bolle

Interesting. If possible you can use the dev console using cmd+option+i or right-click inspect a specific element. And check the computed styling. If you go to font-family you could find the origin where it is defined.

Comment posted by ElisaFo

Yes you are right, my code has some issue!

By