Skip to content

Commit 1d59466

Browse files
authored
Update solutions.md
Adding a solution for the cascade example.
1 parent 32114ae commit 1d59466

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

learn/solutions.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
Solutions for the tasks in the CSS Learn section of MDN.
44

5+
## The Cascade
6+
7+
[Task](https://developer.mozilla.org/en-US/docs/User:chrisdavidmills/CSS_Learn/Cascade_and_inheritance#Active_learning_playing_with_the_cascade)
8+
9+
Task: Write a declaration in a new rule that will reset the background color back to white, without using an actual color value?
10+
11+
One possible solution is as follows:
12+
13+
```
14+
#outer #inner a {
15+
background-color: initial;
16+
}
17+
```
18+
19+
There are two things you need to do in this task. First, you need to write a selector for the `a` element which is more specific than the selector used to turn the background blue. I have achieved this by using the `id` selector which has very high specificity.
20+
21+
Then you need to remember that there are special keyword values for all properties. In this case I am using `inherit` to set the background back to be the same as its parent element.
22+
523
## Attribute Selectors
624

725
[Task](https://developer.mozilla.org/en-US/docs/User:chrisdavidmills/CSS_Learn/CSS_Selectors/Attribute_selectors#Try_it_out)
@@ -56,4 +74,4 @@ h2 {
5674
background-color: rgba(0,0,0,.5);
5775
color: white;
5876
}
59-
```
77+
```

0 commit comments

Comments
 (0)