To assign the attribute to the div element first add a new div element in the CSS Style section at the top part of your code and add ābackground-color: silver;ā. In case youāre not sure where, add it under the last thing you put there which should be ".smaller-image/ width: 100px " attribute. It should look like this:
.smaller-image {
width: 100px;
}
div { <----This will be the new "div" attribute
background-color: silver;
}
Then, after youāve created this, go to the ādivā attribute you already added from the previous lesson (this one is outside of/underneath the CSS Style section). Itās the one you placed before the āThings Cats Loveā paragraph. Inside the opening div tag (
) type class=āsilver-backgroundā. It should look like this:
Hi! I used moebdick90ās technique but it didnāt work. I tried replacing the ādivā in the css with ā.silver-backgroundā but it still didnāt work help please
READ THIS FIRST FOR SIMPLE ANSWER:
By first adding the following to your style, you are making silver available to div as an option to assign:
div {
background-color: silver;
I am still a bit fuzzy on the actual syntax, but when you want to assign it to the actual div you do the following:
(with angled brackets included)
div class=āsilver-backgroundā
Initially I had the same problem. The teaching text to the left hand side of the screen is somewhat misleading in that it demonstrates the use of adding a background by creating a new class and then asks you to create a class and assign.
However,
.green-background {
background-color: green;
}
leads you to believe that you need to add this to the style section (replacing green with silver) and then assign within the div. It sounds like that would work. But if you look at the other elements in style, like h2 and p, you see that the format for applying a class to the entire element follows a different pattern:
h2 {
font-family: Lobster, Monospace;
}
Thus, if you follow this pattern for div:
div {
background-color: silver;
}
and assign it within the div tag you should get the desired result.