Skip to content

Commit 1e1b023

Browse files
committed
words
1 parent 2801a41 commit 1e1b023

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

docs/guide/CSS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,10 @@ The following produces identical results to the previous example, but adds nesti
524524
```{.textual path="docs/examples/guide/css/nesting02.py"}
525525
```
526526

527+
!!! tip
528+
529+
Indenting the rule sets is not strictly required, but it does make it easier to understand how the rule sets are related to each other.
530+
527531
In the first example we had a rule set that began with the selector `#questions .button`, which would match any widget with a class called "button" that is inside a container with id `questions`.
528532

529533
In the second example, the button rule selector is simply `.button`, but it is *within* the rule set with selector `#questions`.
@@ -555,6 +559,10 @@ For reference, lets see those two CSS files side-by-side:
555559
--8<-- "docs/examples/guide/css/nesting02.tcss"
556560
```
557561

562+
563+
Note how nesting bundles related rules together.
564+
If we were to add other selectors for additional screens or widgets, it would be easier to find the rules which will be applied.
565+
558566
### Why use nesting?
559567

560568
There is no requirement to use nested CSS, but it can help to group related rule sets together (which makes it easier to edit). Nested CSS can also help you avoid some repetition in your selectors, i.e. in the nested CSS we only need to type `#questions` once, rather than four times in the non-nested CSS.

0 commit comments

Comments
 (0)