search

Home  >  Q&A  >  body text

Why can't I call my css hyperlink style class from html code?

I want to create multiple classes for hyperlink styles.

I want a default class as well as a special class for the navigation menu.

This is my CSS code:

a {
    color: white;
    text-decoration: none;
}

.menu-items a {
    color: black;
    text-decoration: none;
}

I tried calling the "menu-items" class in the html, but it continues to use the default a{} style shown above.

This is the html code:

<div class="container-outside">
    <div class="container-inside">
        <ul class="ul-list">
            <li>
                <a class="menu-items" href="temperature.html">Temperature</a></li>
            <li>|</li>
            <li>Weight</li>
            <li>|</li>
            <li>Currency</li>
        </ul>
    </div>
</div>

I tried removing the default class and creating two special classes without success. A bit overwhelmed here.

P粉068486220P粉068486220291 days ago470

reply all(2)I'll reply

  • P粉006977956

    P粉0069779562024-04-05 10:31:31

    You can directly put the class name.menu-items

    CSS a { color: white; text-decoration: none; } .menu-items { color: black; text-decoration: none; }

    reply
    0
  • P粉563446579

    P粉5634465792024-04-05 00:58:02

    Your selector is incorrect because menu-items is not the parent of as. You should select the tag like this:

    a.menu-items {
    color: black;
    text-decoration: none;}

    reply
    0
  • Cancelreply