Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / css / last-child-pseudo-class.html
blob32b1a537ff634fc397b82c2cf960de115700dde5
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
3 <html>
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
6 <title>:last-child</title>
8 <style type='text/css'>
9 <!--
11 body { background: #fff; color: 000; font-family: Arial, Helvetica, sans-serif; }
12 pre { background: #fff; padding: 0.5em; }
13 li { background: #aaa; padding: 1em; width: 80%; margin: 0 0 3em; }
14 .test { display: block; padding: 0.75em; }
15 .base, .defaultgreen { background-color: #090; }
16 .defaultred { background-color: #900; }
18 .defaultred :last-child {
19 background-color: #090;
22 .defaultgreen :last-child {
23 background-color: #900;
26 blockquote {
27 margin: 0;
30 -->
31 </style>
32 </head>
34 <body>
35 <p>This page is part of the <a href="http://www.css3.info">CSS3.info</a> <a href="http://www.css3.info/selectors-test/">CSS selectors test</a>. See more info on <a href="http://www.css3.info/preview/attribute-selectors.html">CSS3 selectors</a>.</p>
37 <div class='base'></div>
39 <ol>
40 <li>
41 <div class='defaultred'>
42 <div class='test required'></div>
43 </div>
45 <pre>div :last-child {
48 &lt;div&gt;
49 &lt;div&gt;&lt;/div&gt;
50 &lt;/div&gt;</pre>
52 <p>
53 The CSS selector should match the inner div element, because it is the only child of the outer div element
54 </p>
55 </li>
57 <li>
58 <div class='defaultred'>
59 <blockquote></blockquote>
60 <div class='test'></div>
61 </div>
63 <pre>div :last-child {
66 &lt;div&gt;
67 &lt;blockquote&gt;&lt;/blockquote&gt;
68 &lt;div&gt;&lt;/div&gt;
69 &lt;/div&gt;</pre>
71 <p>
72 The CSS selector should match the inner div element, because it is the last child of the outer div element
73 </p>
74 </li>
76 <li>
77 <div class='defaultred'>
78 <!-- Just a comment -->
79 <div class='test'></div>
80 </div>
82 <pre>div :last-child {
85 &lt;div&gt;
86 &lt;div&gt;&lt;/div&gt;
87 &lt;!-- Just a comment --&gt;
88 &lt;/div&gt;</pre>
90 <p>
91 The CSS selector should match the inner div element, because it is the last child of the outer div element
92 Comments are not elements, so they should not be considered when determining the last child.
93 </p>
94 </li>
96 <li>
97 <div class='defaultred'>
98 <div class='test'></div>
100 </div>
102 <pre>div :last-child {
105 &lt;div&gt;
106 &lt;div&gt;&lt;/div&gt;
107 How about regular text...
108 &lt;/div&gt;</pre>
111 The CSS selector should match the inner div element, because it is the last child of the outer div element.
112 Regular text is not an element, so it should not be considered when determining the last child.
113 </p>
114 </li>
116 <li>
117 <div class='defaultgreen'>
118 <div class='test default required'></div>
119 <blockquote></blockquote>
120 </div>
122 <pre>div :last-child {
125 &lt;div&gt;
126 &lt;div&gt;&lt;/div&gt;
127 &lt;blockquote&gt;&lt;/blockquote&gt;
128 &lt;/div&gt;</pre>
131 The CSS selector should not match the inner div element, because it is the first child of the outer div element
132 </p>
133 </li>
135 <li>
136 <div class='defaultred'>
137 <div id='insertAfter1'></div>
138 </div>
140 <script type="text/javascript">
141 <!--
143 var ib = document.getElementById('insertAfter1');
144 var el = document.createElement("div");
145 el.className = 'test';
146 ib.parentNode.appendChild(el);
149 //-->
150 </script>
152 <pre>div :last-child {
155 &lt;div&gt;
156 &lt;div id='insertAfter'&gt;&lt;/div&gt;
157 &lt;/div&gt;
159 var ib = document.getElementById('insertAfter');
160 ib.parentElement.appendChild(document.createElement("div"));</pre>
163 The CSS selector should match the div element that is inserted by the Javascript code.
164 </p>
165 </li>
167 <li>
168 <div class='defaultgreen'>
169 <div id='insertAfter2' class='test default'></div>
170 </div>
172 <script type="text/javascript">
173 <!--
175 var ib = document.getElementById('insertAfter2');
176 ib.parentNode.appendChild(document.createElement("div"));
178 //-->
179 </script>
181 <pre>div :last-child {
184 &lt;div&gt;
185 &lt;div id='insertAfter'&gt;&lt;/div&gt;
186 &lt;/div&gt;
188 var ib = document.getElementById('insertAfter');
189 ib.parentElement.appendChild(document.createElement("div"));</pre>
192 The original div element should not be a match for the :last-child selector.
193 </p>
194 </li>
195 </ol>
196 </body>
197 </html>