-3

I am trying to add the hover pseudoclass and apply the following styles:

Background color must be #eee
Use gray for font color

I have done it in two ways:

#container :hover {

    background-color: #eee;
    color: gray;
}

    </style>
  </head>
  <body>
    <div id="container">
      <a href="#">link</a>
      <a href="#">link</a>
      <a href="#">link</a>
      <a href="#">link</a>
      <a href="#">link</a>
    </div>

The other one is by selecting div.

div :hover {

    background-color: #eee;
    color: gray;
}

The problem is the last one changes the background color but not the font color. I can not understand what is going on.

dippas
  • 58,591
  • 15
  • 114
  • 126
Hanna
  • 539
  • 2
  • 9
  • 24

1 Answers1

0

To change the font color you have to apply the styles to a tag.

#container:hover {
background-color: #eee;
}

#container a:hover{
color: gray;
}
Bhawna Saroha
  • 603
  • 1
  • 11
  • 28