Skip to content

Commit f433516

Browse files
authored
Update README.md
1 parent 30024a0 commit f433516

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

README.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@ parent element), then pasting it where you want.
1818
## Examples
1919
See how Scoped CSS works in practice, how we use it, how you may want to use it!
2020

21+
### The basics
2122
1. Here's how you use scoped CSS. Add `class="scoped"` to your `<style>` element.
2223
2. Then use `\&` for all the CSS rules that you want to be scoped.
2324
```html
2425
<div>
2526
<style class="scoped">
26-
\& {
27-
background: lightblue;
28-
}
2927
\& p {
3028
color: navy;
3129
}
@@ -34,3 +32,24 @@ See how Scoped CSS works in practice, how we use it, how you may want to use it!
3432
<p> Scoped CSS fits some situations really well. </p>
3533
</div>
3634
```
35+
Only **this `<p>` will show up as navy-colored the rest stay normal**.
36+
Also, scoped CSS elements can still take on styles from non-scoped style sheets
37+
if you have `p { font-size: 2em; }` for example.
38+
39+
### Scoped CSS doesn't bleed!
40+
1. The "First H2" stays the default color.
41+
2. Only the "Second H2" get's the new color from our scoped CSS.
42+
```html
43+
<body>
44+
<div>
45+
<h2> First H2 </h2>
46+
</div>
47+
<div>
48+
<style class="scoped">
49+
\& h2 { color: firebrick; }
50+
</style>
51+
<h2> Second H2 </h2>
52+
</div>
53+
</body>
54+
```
55+

0 commit comments

Comments
 (0)