summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-nesting/nesting-basic.html
blob: 19ff48e4a29588e48eb19570149ad7525827cd8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!DOCTYPE html>
<title>Basic nesting</title>
<link rel="author" title="Adam Argyle" href="mailto:argyle@google.com">
<link rel="help" href="https://drafts.csswg.org/css-nesting-1/">
<link rel="match" href="nesting-basic-ref.html">
<style>
  .test {
    background-color: red;
    width: 30px;
    height: 30px;
    display: grid;
  }

  .test-1 {
    & > div {
      background-color: green;
    }
  }

  .test-2 {
    & > div {
      background-color: green;
    }
  }

  .test-3 {
    & .test-3-child {
      background-color: green;
    }
  }

  span > b {
    .test-4 section & {
      display: inline-block;
      background-color: green;
      width: 100%;
      height: 100%;
    }

    .test-4 section > & {
      background-color: red;
    }
  }

  .test-6 {
    &.test {
      background-color: green;
    }
  }

  .test-7, .t7- {
    & + .test-7-child, &.t7-- {
      background-color: green;
    }
  }

  .test-8 {
    & {
      background-color: green;
    }
  }

  .test-9 {
    &:is(.t9-, &.t9--) {
      background-color: green;
    }
  }

  .test-10 {
    & {
      background-color: green;
    }
    background-color: red;
  }

  .test-11 {
    & {
      background-color: red;
    }
    background-color: green !important;
  }

  /* & at top level counts as :scope, i.e. the root element here */
  & .test-12 {
    background-color: green;
  }
  & > .test-12 {
    background-color: red !important;
  }

  body * + * {
    margin-top: 8px;
  }
</style>
<body>
  <p>Tests pass if <strong>block is green</strong></p>
  <div class="test test-1"><div></div></div>
  <div class="test test-2"><div></div></div>
  <div class="test test-3"><div class="test-3-child"></div></div>
  <div class="test test-4">
    <section>
      <span><b></b></span>
    </section>
  </div>
  <div class="test test-6"><div></div></div>
  <div class="test t7- t7--"><div class="test-7-child"></div></div>
  <div class="test test-8"><div></div></div>
  <div class="test test-9 t9-- t9-"><div></div></div>
  <div class="test test-10"><div></div></div>
  <div class="test test-11"><div></div></div>
  <div class="test test-12"></div>
</body>