Skip to content

Commit 748eed9

Browse files
committed
module 3.4.2
1 parent 75f702c commit 748eed9

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!DOCTYPE html>
2+
<!--It's a best practice to always declare DOCTYPE!-->
3+
<html lang="en">
4+
<head>
5+
<meta charset="utf-8">
6+
</head>
7+
<body>
8+
<header>
9+
<h1>Title</h1>
10+
<ol>
11+
<li>Blog Post 1</li>
12+
<li>Blog Post 2</li>
13+
<li>Blog Post 3</li>
14+
</ol>
15+
<p>
16+
When you use two selectors separated by a space on a rule, you scope the rule to the elements that correspond to the selector on the right that are INSIDE the elements that correspond to the selector on the left. Let's say we have the following HTML:
17+
</p>
18+
</header>
19+
<section>
20+
<h2>Blog Post 1</h2>
21+
<p>
22+
If we applied the following CSS rule then the images INSIDE the paragraph would be set to a width of 100px, but that rule would not apply to the images outside the paragraph.
23+
</p>
24+
<ol>
25+
<li>Below is a diagram of the given HTML</li>
26+
<li>with the two imgs that will styled by the above rule are indicated by the red arrows</li>
27+
<li>As your Web pages get more complex, contextual selectors become more important</li>
28+
</ol>
29+
</section>
30+
<section>
31+
<h2>Blog Post 2</h2>
32+
<p>
33+
because it won't scale to apply classes and IDs to each individual item. Contextual selection becomes especially useful when you structure your HTML with section tags like header, section, article and footer.
34+
</p>
35+
<ol>
36+
<li>Here is some code where you can see contextual selectors in action</li>
37+
<li>Note that there are differences between p elements and also differences between ol elements.</li>
38+
</ol>
39+
</section>
40+
</body>
41+
</html>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
p {
2+
color: red;
3+
}
4+
5+
section p {
6+
color: blue;
7+
}
8+
9+
ol {
10+
list-style-type: upper-roman;
11+
}
12+
section ol {
13+
list-style-type: lower-roman;
14+
}

0 commit comments

Comments
 (0)