-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.html
1570 lines (1275 loc) · 44.1 KB
/
index.html
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE HTML>
<html>
<head>
<!--[if gte IE 9]><meta http-equiv="X-UA-Compatible" content="IE=edge" /><![endif]-->
<!--[if lt IE 9]><meta http-equiv="X-UA-Compatible" content="IE=edge;chrome=1" /><![endif]-->
<meta charset="utf-8" />
<title>Selectors: Select This!</title>
<link href='https://fonts.googleapis.com/css?family=Rum+Raisin' rel='stylesheet'>
<link href='https://fonts.googleapis.com/css?family=Bigelow+Rules' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="white.css"/>
<style>
.current * { -webkit-tap-highlight-color: #bada55;}
.thisSlide.foo {
-webkit-tap-highlight-color: #bada55;
-webkit-user-select: none;
-webkit-touch-callout: none;
}
.beforeafter:before {
content: "before - ";
font-weight: bold;
}
.beforeafter:after {
content: " - after";
font-weight: bold;
}
.active {color: red; font-weight: bold; background-color: rgba(0,0,0,0.3)}
#presentation {-webkit-animation: none; background-image: none;}
</style>
</head>
<body>
<!-- Top instructions -->
<div id="topinfo"></div>
<!-- footer instructions -->
<div id="info">
<p><a href="http://standardista.com">Estelle Weyl</a> | <a href="https://twitter.com/estellevw">@estellevw</a> | <a href="https://github.com/estelle">Github</a> | Press <span class="key">→</span> key to advance.</p>
</div>
<div id="presentation">
<div id="presentation-counter"></div>
<div id="slides">
<div class="slide intro">
<header><hgroup>
<h1><span class="textmask">Select This!</span><br> CSS Selectors</h1>
</hgroup></header>
<p><a href="https://estelle.github.com/selectors/" style="color: #000">https://estelle.github.com/selectors/</a></p>
</div>
<div class="slide normal">
<header><h1>Me</h1></header>
<section class="content">
<h1 class="textmask">Estelle Weyl</h1>
<h2><a href="http://www.standardista.com">www.standardista.com</a></h2>
<h2><a href="https://www.twitter.com/estellevw">@estellevw</a></h2>
<h2><a href="https://www.twitter.com/standardista">@standardista</a></h2>
<div style="float:right"><img src="https://akamaicovers.oreilly.com/images/9780987467485/cat.gif" alt="HTML5 and CSS3 for the Real World"><img src="https://akamaicovers.oreilly.com/images/0636920012726/cat.gif" alt="CSS: The Definitive Guide" style="margin: 0 20px;"><img src="https://akamaicovers.oreilly.com/images/0636920021711/cat.gif" alt="MObile HTML5" style="margin: 0 20px;"><img src="https://akamaicovers.oreilly.com/images/0636920025955/cat.gif" alt="Web Performance Daybook"></div>
</section>
</div>
<!-- basics -->
<div class="slide normal">
<header><h1>Selectors</h1></header>
<section class="content">
<pre contenteditable style="font-size:100%; line-height:1.5">selectorA {
property1: value1;
property2: value2;
}
selectorB {
property1: value3;
property2: value4;
}</pre>
</section>
</div>
<div class="slide normal">
<header><h1>Selectors</h1></header>
<section class="content">
<pre contenteditable style="font-size:100%; line-height:1.5">selector:pseudo-class::pseudo-element {
-vendor-property: value;
}
selector[attribute],
selector ~ relation {
property: -vendor-value;
-vendor-property: -vendor-value;
-vendor-property: weirdsyntax;
}</pre>
</section>
</div>
<!-- Basic Selectors-->
<div class="slide normal light" id="slcElement">
<header><h1>Basic Selectors</h1></header>
<section class="content">
<pre contenteditable style="font-size:100%; line-height:1.5"><ul>
<li id="myID" class="myClass">item 1</li>
<li class="myClass">item 2</li>
<li>item 3</li>
</ul> </pre>
<dl class="inline">
<dt><b class="imp">#</b>myID</dt>
<dd>ID</dd>
<dt><b class="imp">.</b>myClass</dt>
<dd>class</dd>
<dt class="imp">li</dt>
<dd>tag name</dd>
</dl>
</section>
</div>
<div class="slide object">
<header><h1>Play Time</h1></header>
<object data="files/00_basics.html"></object>
<a href="files/00_basics.html" target="play" class="objectlink">Try it out</a>
</div>
<!-- selectors in CSS1 -->
<div class="slide">
<header><h1>Selectors in CSS Level 1</h1></header>
<section class="content">
<pre contenteditable style="font-size:100%; line-height:1.5">E
E F
.class
#ID
:link
:active</pre>
</section>
</div>
<!-- Play time
<div class="slide object">
<header>
<h1>Play Time</h1>
</header>
<object data="files/00_basic.html"></object>
<a href="files/00_basic.html" target="play" class="objectlink">Try it out</a>
</div>
<!-- Selector list -->
<div class="slide normal">
<header>
<h1>Lots 'o Selectors</h1>
</header>
<section class="content">
<ul class="columns">
<li style="column-span: all"><h3>CSS Level 1 Selectors</h3></li>
<li>E</li>
<li>.class</li>
<li>#id</li>
<li>E F</li>
<li>:link</li>
<li>:active</li>
<li style="column-span: all"><h3>CSS Level 2 Selectors</h3></li>
<li>*</li>
<li>E > F</li>
<li>E + F</li>
<li>E[attribute]</li>
<li>E[attribute=value]</li>
<li>E[attribute~=value]</li>
<li>E[attribute|=value]</li>
<li>:first-child</li>
<li>:lang(en)</li>
<li>:focus</li>
<li>:hover</li>
<li>:visited</li>
<li>:before</li>
<li>:after</li>
<li>:first-letter</li>
<li>:first-line</li>
</ul>
</section>
</div>
<!-- Selector list -->
<div class="slide normal">
<header>
<h1>Lots 'o Selectors</h1>
</header>
<section class="content">
<ul class="columns">
<li style="column-span: all"><h3>CSS Selects Level 3</h3></li>
<li>::before</li>
<li>::after</li>
<li>::first-letter</li>
<li>::first-line</li>
<li><br/>E[attribute^=value]</li>
<li>E[attribute$=value]</li>
<li>E[attribute*=value]</li>
<li><br/>E ~ F</li>
<li>:root</li>
<li>E:last-child</li>
<li>E:only-child</li>
<li>E:nth-child(n)</li>
<li>E:nth-last-child(n)</li>
<li>E:first-of-type</li>
<li>E:last-of-type</li>
<li>E:only-of-type</li>
<li>E:nth-of-type(n)</li>
<li>E:nth-last-of-type(n)</li>
<li><br/>E:empty</li>
<li>E:not(selector)</li>
<li>E:target</li>
</ul></section></div>
<!-- Selector list -->
<div class="slide normal">
<header>
<h1>Lots 'o Selectors</h1>
</header>
<section class="content">
<ul class="columns">
<li style="column-span: all"><h3>UI / Selectors #4</h3>
<li>E:enabled</li>
<li>E:disabled</li>
<li>E:checked</li>
<li>E:default</li>
<li>E:valid</li>
<li>E:invalid</li>
<li>E:in-range</li>
<li>E:out-of-range</li>
<li>E:required</li>
<li>E:optional</li>
<li>E:read-only</li>
<li>E:read-write</li>
</ul>
</section>
</div>
<div class="slide normal">
<header>
<h1>CSS Selectors Level 4</h1>
</header>
<section class="content">
<ul class="columns">
<li>:blank</li>
<li>:indeterminate</li>
<li>:placeholder-shown</li>
<li>:not(s1, s2)</li>
<li>:matches(s1, s2)</li>
<li>:has(rs1, rs2)</li>
<li>[foo="bar" i]</li>
<li>:dir(ltr)</li>
<li>:lang(zh, *-hant)</li>
<li>:any-link</li>
<li>:scope</li>
<li>:current</li>
<li>:focus-ring</li>
<li>:drop</li>
<li>:drop(active)</li>
<li>:drop(valid)</li>
<li>:drop(invalid)</li>
<li>:user-invalid</li>
<li>E >> F</li>
<li>F || E</li>
<li>:nth-column(n)</li>
<li>:nth-last-column(n)</li>
</ul>
</section></div>
<!-- Selector list -->
<div class="slide normal">
<header>
<h1>More... </h1>
</header>
<section class="content">
<h3>Maybe</h3>
<ul class="columns">
<li>::selection</li>
<li>:scope-context()</li>
<li>:current(s)</li>
<li>:past</li>
<li>:future</li>
<li>:host</li>
<li>:host()</li>
<li>:host-context()</li>
<li>::shadow</li>
<li>::content</li>
<li><s>:column(selector)</s></li>
<li><strike>E /foo/ F</strike></li>
<li><strike>E! > F</strike></li>
<li><s>:local-link</s></li>
<li><s>:nth-match()</s></li>
</ul>
</section>
</div>
<div class="object slide">
<object data="selectors.html"></object>
<header><h1>All the selectors</h1></header>
<a href="selectors.html" target="play" class="objectlink" aria-label="open all the selectors in new window">Open</a>
</div>
<div class="object slide">
<object data="https://specifishity.com/" style="height: 792px;"></object>
<header><h1>Specificity (SpeciFISHity)</h1></header>
<a href="https://specifishity.com/specifishity.pdf" target="play" class="objectlink">Download</a>
</div>
<!-- Specificity Notes -->
<div class="slide normal">
<header><h1>Specificity: How it works</h1></header>
<section class="content">
<ul>
<li><code contenteditable>1-0-0</code>: ID selector</li>
<li><code contenteditable>0-1-0</code>: Class selector (Also attribute selector & pseudoclass)</li>
<li><code contenteditable>0-0-1</code>: Element Selector</li>
<p>The * selector, or global selector, has no value.</p>
<pre contenteditable>* {} 0-0-0 </pre>
<p>Combinators, like ~, >, and + have no value</p>
<pre contenteditable>ul li {} 0-0-2
ul > li {} 0-0-2</pre>
</section>
</div>
<!-- Relational selectors -->
<div class="slide normal" id="slcRelational">
<header><h1>Relational selectors & Combinators</h1></header>
<section class="content">
<div class="ex right">
<ol>
<li>item 1</li>
<li>item 2</li>
<li>item 3
<ul>
<li>item a</li>
<li>item b</li>
<li>item c</li>
</ul>
</li>
<li class="hasaclass">hasaclass</li>
<li>item 5</li>
<li>item 6</li>
<li>item 7</li>
</ol>
</div>
<dl>
<dt><span onclick="hasaclass('ul li');">ul li</span>, <br><span onclick="hasaclass('ol li');">ol li</span></dt>
<dd>descendant selector<br />
matches nested <li>s
</dd>
<dt onclick="hasaclass('ol > li');">ol > li</dt>
<dd><em>child selector</em> <br />
matches <li>s in <ol> but not nested <ul></dd>
<dt onclick="hasaclass('li.hasaclass + li');">li.hasaclass + li</dt>
<dd><em>adjacent sibling</em> </dd>
<dt onclick="hasaclass('li.hasaclass ~ li');"><strong class="new">NEW </strong><span style="background-color:#eee; padding:3px 20px; position:relative; left: 22px; margin-left: -20px;">(IE7+)</span><br />
li.hasaclass ~ li</dt>
<dd><em>general sibling selector</em><br />
matches later siblings, but not nested.</dd>
<dt>E >> F</dt>
<dd>NEW: descendant combinator</dd>
</dl>
</section>
<script defer>
function hasaclass(selector) {
var i = j = 0,
elements = document.querySelectorAll('.current .ex li'),
update = document.querySelectorAll('.current .ex ' + selector);
for (; i < elements.length; i++) {
elements[i].classList.remove('active');
}
for (; j < update.length; j++) {
update[j].classList.add('active');
}
}
</script>
</div>
<div class="slide normal">
<header><h1>Selectors API</h1></header>
<section class="content">
<pre contenteditable>var chil = $('#bar .foo');</pre>
<p>Natively</p>
<pre contenteditable>var el = document.<strong>querySelector</strong>('#bar');
var chil = el.<strong>querySelectorAll</strong>('.foo');</pre>
<p>or</p>
<pre contenteditable>chil = document.<strong>querySelectorAll</strong>('#bar .foo');</pre>
</section>
</div>
<!-- Attribute selectors-->
<div class="slide normal">
<header>
<h1>Attribute selectors</h1>
</header>
<section class="content">
<dl>
<dt>element[attribute]</dt>
<dd>Select elements containing the named attribute</dd>
</dl>
<pre contenteditable style="font-size: 95%;"><strong>img[alt] {}</strong>
<img src="image.jpg" <strong>alt</strong>="accessible">
<span style="opacity:0.3"><img src="image.jpg" title="inaccessible"></span>
<strong>form [type] {}</strong>
<input <strong>type</strong>=date>
<span style="opacity:0.3"><select></span></pre>
</section>
</div>
<!-- Older attribute selectors -->
<div class="slide normal">
<header style="position:absolute; top: 20px; right: 20px;">
<h1>CSS 2 attribute selectors</h1>
</header>
<section class="content">
<dl>
<dt>E[attr]</dt>
<dd>Element E that has the attribute attr with any value.</dd>
<dt>E[attr="val"]</dt>
<dd>Element E that has the attribute attr with the exact, case-sensitive if attribute is case sensitive, value <em>val</em>.</dd>
<dt>E[attr|=val]</dt>
<dd>Element E whose attribute <em>attr</em> has a value <em>val</em> or begins with val- ("val" plus "-").<br />
<pre contenteditable class="example">p[lang|="en"]{/* <p lang="en-us"> <p lang="en-uk"> */ }</pre>
</dd>
<dt>E[attr~=val]</dt>
<dd>Element E whose attribute <em>attr</em> has within its value the space-separated full word <em>val</em>.<br />
<pre contenteditable class="example">a[title~=more] {/* <a title="want more info about this?">}</pre>
</dd>
</dl>
</section>
</div>
<!-- CSS3 Attribute Selectors -->
<div class="slide normal">
<header style="position:absolute; top: 20px; right: 20px;"><h1>Attribute Selectors in CSS Selectors Level 3</h1></header>
<section class="content">
<dl>
<dt>E[attr^=val]</dt>
<dd>Element E whose attribute <em>attr</em> starts with the value <em>val</em>.<br />
<pre contenteditable class="example">a[href^=mailto] {background-image: url(emailicon.gif);}
a[href^=http]:after {content: " (" attr(href) ")";}</pre>
</dd>
<dt>E[attr$=val]</dt>
<dd>Element E whose attribute <em>attr</em> ends in <em>val</em> . <br />
<pre contenteditable class="example">a[href$=pdf] {background-image: url(pdficon.gif);}
a[href$=pdf]:after {content: " (PDF)";}</pre>
</dd>
<dt>E[attr*=val]</dt>
<dd>Element E whose attribute <em>attr </em>matches <em>val</em> anywhere within the attribute. Similar to E[attr~=val] above, except the <em>val</em> can be part of a word.</dd>
</dl>
<p>Note: Multiple attributes work! a[title][href]</p>
</section>
</div>
<!-- CSS4: Attribute Selector -->
<div class="slide">
<header>
<h1>Attribute Selectors 4: Case Insensitivity</h1>
</header>
<section class="content">
<pre contenteditable>E[foo="bar" i]</pre>
<pre contenteditable class="example">input[type=checkbox i]</pre>
<p>Only relevant if attribute value is case senstive <br/>(as it is for all attributes in XHTML)</p>
<p><a href="https://codepen.io/estelle/pen/lEGev" target="_play">CodePen test page</a>
</section>
</div>
<!--
<div class="object slide">
<object data="files/01_attr_caseinsensitiveB.html"></object>
<header><h1>Case Sensitivity</h1></header>
<a href="files/01_attr_caseinsensitiveB.html" target="play" class="objectlink" aria-label="open all the selectors in new window">Open</a>
</div>
selectors css 2
<div class="slide">
<header><h1>Selectors in CSS Level 2</h1></header>
<section class="content" style="line-height: 1.5">
<pre>*
:lang(en)
:hover
:focus
E > F
E + F
:first-child
[attribute]
[attribute="value"]
[attribute~="value"]
[attribute|="en"]</pre>
</section>
</div>
-->
<!-- Attribute Selectors Recap -->
<div class="slide normal">
<header><h1>Attribute Selectors Recap</h1></header>
<section class="content">
<pre contenteditable style="float:left; width: 45%; margin: 0 20px 0 0;">
input[placeholder] {<b class="notes">/* matches any input with a placeholder */</b>}
input[type=email] {<b class="notes">/* exact match */</b>}
abbr[title~=unicorn] {<b class="notes">/* matches unicorn but not unicorns */</b>}
abbr[title|=en] {<b class="notes">/* matches en-us and en-uk */</b>}
a[href^=mailto] {<b class="notes">/* starts with */</b>}
a[href$=pdf]{<b class="notes">/* ends in */</b>}
abbr[title*=unicorn] {<b class="notes">/* matches unicorn and unicorns */</b>}
abbr[title*=UNICORN i] {<b class="notes">/* matches unicorn and UnIcOrNs */</b>}
</pre>
<pre contenteditable style="float:left; width: 40%; margin-top:0;">E:[att] <b class="notes">/* have the attribute at all */</b>
E:[att=val] <b class="notes">/* exact */</b>
E:[att~=val] <b class="notes">/* val is a space separated word */</b>
E:[att|=val] <b class="notes">/* with a dash */</b>
E:[att^=val] <b class="notes">/* begins with val */</b>
E:[att$=val] <b class="notes">/* ends with val */</b>
E:[att*=val] <b class="notes">/* val is anywhere as a substring */</b>
E:[att*=VAL i] <b class="notes">/* anywhere as a case insenstive substring */</b></pre>
<pre contenteditable style="clear:both">
@media print{
abbr[title]:after {
content: "(" attr(title) ")";
}
a[href^=http]:after {
content: "(" attr(href) ")";
}
}</pre>
</section>
</div>
<!-- Using attribute selectors -->
<div class="slide object">
<object data="files/01_attr.html"></object>
<header><h1>Using attribute selectors</h1></header>
<a href="files/01_attr.html" target="play" class="objectlink">Attribute Selectors</a>
<p><strong>Note:</strong> The top line of the example is editable. The CSS will impact the contents on the rest of the page.</p>
</div>
<!-- UI pseudo-classes -->
<div class="slide normal">
<header><h1>UI pseudo-classes</h1></header>
<section class="content">
<p>Based on current state of UI </p>
<pre contenteditable>
:enabled
:disabled
:checked
:indeterminate (Level 4)</pre>
<pre contenteditable class="example">input[type=checkbox]:checked + label {
color: red;
}</pre>
<div style="clear:both;">
<input type="checkbox" id="test1ck"/> <label for="test1ck">Check and Uncheck Me</label><br/>
<input type="checkbox" id="test2ck"/> <label for="test2ck">Check and uncheck me too!</label></div> </section>
<footer>Basic User Interface Module Level 3 (CSS3 UI)</footer></div>
<!--Form related UI pseudo-classes -->
<div class="slide normal">
<header><h1>Form related UI pseudo-classes</h1></header>
<section class="content">
<pre contenteditable style="font-size: 1.8rem;" class="columns">:default
:valid
:invalid
:required
:optional
:in-range
:out-of-range
:read-only
:read-write
:placeholder-shown
:user-invalid</pre>
</section>
</div>
<!--Form related UI pseudo-classes -->
<div class="slide normal">
<header><h1>Form related UI pseudo-classes</h1></header>
<section class="content">
<pre contenteditable class="example">input:valid { border: 1px solid green;}
input:invalid { border: 1px solid red;}
input:required,
input[aria-required="true"] {border-width: 5px;}
input:optional {border-width: 10px;}
input:out-of-range { background-color: pink;}
input:in-range { background-color:lightgreen;}</pre>
<div style="clear:both;">
<input type="number" min="5" max="7" id="test3ck" required/> <label for="test3ck">Number between 5 and 7</label><br>
<input type="number" min="0" step="0.1" max="10" id="test4ck"/><label for="test4ck">Number between 0 and 10</label>
<pre contenteditable class="example"><input type="number" min="5" max="7"
required aria-required="true"/>
<input type="number" min="0" step="0.1" max="10"/>
</pre>
</div> </section>
</div>
<!-- UI selectors -->
<div class="slide object">
<object data="files/02_uiselectors.html"></object>
<header><h1>UI selectors</h1></header>
<a href="files/02_uiselectors.html" target="play">UI Selectors</a></h1>
<p>Test them out for yourselves</p>
<a class="objectlink" href="files/02_uiselectors.html">Open in new page</a>
</div>
<!-- UI selectors -->
<div class="slide object">
<object data="files/02_counting.html?hop"></object>
<header><h1>UI selectors</h1></header>
<a href="files/02_uiselectors.html" target="play">UI Selectors</a></h1>
<p>Test them out for yourselves</p>
<a class="objectlink" href="files/02_counting.html">Open in new page</a>
</div>
<!-- List of Structural selectors -->
<div class="slide normal">
<header><h1>Structural selectors</h1></header>
<section class="content">
<pre contenteditable class="columns2">
:root
:empty
:blank
:nth-child()
:nth-last-child()
:first-child<sup style="color:#C61800"> (2)</sup>
:last-child
:only-child
:nth-of-type()
:nth-last-of-type()
:first-of-type
:last-of-type
:only-of-type
</pre>
<ul><li>Target elements on the page based on their relationships to other elements in the DOM.</li>
<li>Updates dynamically if page updates.</li>
<li>Reduced need for extra markup, classes and IDs</li>
</ul>
</section>
</div>
<!--First, last, & only -->
<div class="slide normal">
<header><h1>First, last, & only</h1></header>
<section class="content">
<pre contenteditable>
:first-child
:last-child
:first-of-type
:last-of-type
:only-child
:only-of-type
</pre>
<p>Easier to explain <a href="files/04_firstlastonly.html" target="play">by example</a></p>
</section>
</div>
<div class="slide object">
<object data="files/04_firstlastonly.html"></object><header><h1>First, last, & only</h1></header>
<a href="files/04_firstlastonly.html" class="objectlink" target="play">First, last and only</a>
</div>
<!--nth pseudo-classes -->
<div class="slide normal">
<header><h1>nth pseudo-classes</h1></header>
<section class="content">
<pre contenteditable class="example">:nth-child(<b>3n</b>)
:nth-last-child(<b>odd</b>)
:nth-of-type(<b>5</b>)
:nth-last-of-type(<b>3n+1</b>) </pre>
<p>Target element or elements based on argument passed to the selector</p>
<ul class="pre">
<li>:nth-of-type(<b>even</b>)</li>
<li>:nth-of-type(<b>odd</b>)</li>
<li>:nth-of-type(<b>an+b</b>) </li>
</ul>
</section>
</div>
<!--Structural Selectors -->
<div class="slide normal">
<header><h1>Structural Selectors</h1></header>
<section class="content">
<pre contenteditable style="margin-top: 0; float: left;">
li:<b>first-child</b>,
li:<b>last-child</b> {
font-weight: bold;
}
li:<b>first-of-type</b>,
li:<b>last-of-type</b>{
text-decoration:line-through;
}
li:<b>nth-child</b>(<b>even</b>) {
background-color: #CCC;
}
li:nth-child(<b>3</b>) {
color: #CCC;
}
li:<b>nth-of-type</b>(<b>odd</b>) {
background-color: #FFF;
}
li:nth-of-type(<b>4n</b>) {
color: hsl(205, 87%, 50%);
}
li:nth-of-type(<b>3n-1</b>) {
text-align: right;
}
</pre>
<ul class="structural" style="float: right; width:33%;">
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
<li>item 4</li>
<li>item 5</li>
<li>item 6</li>
<li>item 7</li>
<li>item 8</li>
<li>item 9</li>
<li>item 10</li>
</ul>
</section>
</div>
<!--Advanced Structural Selectors -->
<div class="slide normal">
<header><h1>Before Flexbox</h1></header>
<section class="content" style="height: 80%; overflow: scroll;">
<ul class="count"><li>1</li></ul>
<ul class="count"><li>1</li><li>2</li></ul>
<ul class="count"><li>1</li><li>2</li><li>3</li></ul>
<ul class="count"><li>1</li><li>2</li><li>3</li><li>4</li></ul>
<pre contenteditable class="example"> li:only-of-type{width: 100%;}
li:nth-of-type(1):nth-last-of-type(2),
li:nth-of-type(2):nth-last-of-type(1) {width: 50%;}
li:nth-of-type(1):nth-last-of-type(3),
li:nth-of-type(3):nth-last-of-type(1),
li:nth-of-type(2):nth-last-of-type(2) {width: 33.33%;}
li:nth-of-type(1):nth-last-of-type(4), li:nth-of-type(1):nth-last-of-type(4) ~ li {width: 25%;}</pre>
</section>
</div>
<div class="slide object">
<object data="files/05_nth.html"></object>
<header><h1>Structural Selectors</h1></header>
<a href="files/05_nth.html" target="play" class="objectlink">Structural Selectors</a>
</div>
<div class="slide object">
<object data="files/05_flag.html#flag"></object>
<header><h1>Flag with Structural Selectors</h1></header>
<a href="files/05_flag.html" target="play" class="objectlink">USA Flag</a>
</div>
<div class="slide object">
<object data="files/05_flag2.html#flag"></object>
<header><h1>Simpler Flag with Structural Selectors</h1></header>
<a href="files/05_flag2.html" target="play" class="objectlink">USA Flag</a>
</div>
<!-- nth-matchnes()
<div class="slide">
<header><h1>Structural Selectors Level 4</h1></header>
<section class="content double">
<pre contenteditable>E:nth-match(n of selector)
E:nth-last-match(n of selector)</pre>
<pre contenteditable class="example">li:nth-match(2n of .foo)
li:nth-last-match(3n+1 of .bar)</pre>
</section>
</div>
-->
<!--root -->
<div class="slide normal">
<header><h1>:root</h1></header>
<section class="content">
<pre contenteditable>
:root
</pre>
<p>Selects the document root, which is <html></p>
<ul><li>Declare <em>font-size</em> on <strong>:root</strong> if using <strong>rem</strong> units</li>
<li>Style <strong>:root</strong> only if showing <strong><head></strong> (as in our exercise files)</li>
<li>In CSS4, define Defining Variables on root. (see <a href="https://dev.w3.org/csswg/css-variables/" target="play">Variables module</a>)</li>
</ul>
<p><small><a href="files/03_root.html" target="play">example</a></small></p>
</section>
</div>
<!-- :empty pseudo-class -->
<div class="slide normal">
<header><h1>:empty & :blank pseudo-classes </h1></header>
<section class="content">
<pre contenteditable>E<b>:empty</b></pre>
<pre contenteditable><E/>
<E></E>
<E><!-- this is a comment --></E>
<E title="this is an empty element"/></pre>
<hr/>
<p>No browser support...
<pre contenteditable>E<b>:blank</b></pre>
<pre contenteditable><E> <!-- has white space --> </E></pre><small>
:-moz-whitespace-only</small>
</section>
</div>
<!-- :not(s) -->
<div class="slide normal">
<header><h1><strong>:not</strong> - Negation pseudo-class</h1></header>
<section class="content">
<pre contenteditable>E<b contenteditable="false">:not(</b>s1<b contenteditable="false">)</b></pre>
<pre contenteditable class=" example">div<b contenteditable="false">:not(</b>.excludeMe<b contenteditable="false">)</b></span></pre>
<p>Supported everywhere since IE9</p>
</section>
</div>
<!-- :not(s1, s2) -->
<div class="slide normal">
<header><h1><strong>:not(s1, s2)</strong> </h1></header>
<section class="content">
<pre contenteditable>E<b contenteditable="false">:not(</b>s1, s2<b contenteditable="false">)</b></pre>
<pre contenteditable class=" example">div<b contenteditable="false">:not(</b>.excludeMe, .excuseYou<b contenteditable="false">)</b></span></pre>
<p><a href="https://caniuse.com/#feat=css-not-sel-list" target="play">Safari Only</a></p>
</section>
</div>
<div class="slide object">
<object data="files/06_not.html"></object>
<header><h1><strong>:not</strong> - Negation pseudo-class</h1></header>
<a href="files/06_not.html" target="play" class="objectlink">Negation Selectors</a>
</div>
<div class="slide">
<header><h1>:matches(s1, s2)</h1></header>
<section class="content">
<pre contenteditable>E:matches(s1, s2)</pre><hr/>
<pre class="example" contenteditable>li<b contenteditable="false">:matches(</b>[title]<b contenteditable="false">,</b> [role]<b contenteditable="false">) a</b> {}</pre>
<pre>li[title] a,
li[role] a {}</pre>
<hr/>
<pre class="example" contenteditable><b contenteditable="false">:matches(</b>#home, #contact<b contenteditable="false">)</b> aside :matches(a:active, a:focus){}</pre>
<pre class="example" contenteditable>#home aside a:active,
#contact aside a:active,
#home aside a:focus,
#contact aside a:focus {}</pre>
<p><a href="https://caniuse.com/#feat=css-matches-pseudo">Safari only</a></p>
</section>
</div>
<div class="slide">
<header><h1>Experimental :any</h1></header>
<section class="content">
<pre contenteditable>E:matches(s1, s2)</pre>
<pre contenteditable class="example" >:-webkit-any(article, aside) :-webkit-any(article, aside) h1,
:-moz-any(article, aside) :-moz-any(article, aside) h1 {
}</pre><pre contenteditable class="example" >
a:matches(.foo, .bar, .bam) span,
a:-webkit-any(.foo, .bar, .bam) span,
a:-moz-any(.foo, .bar, .bam) span {
}</pre><pre contenteditable class="example" >
nav a:not(:matches(.foo, .bar, .bam)),
nav a:not(:-webkit-any(.foo, .bar, .bam)),
nav a:not(:-moz-any(.foo, .bar, .bam)),
nav a:not(.foo, .bar, .bam) {
}
nav a:not(.foo):not(.bar).not(.bam){
}
</pre>
</section>
</div>
<!-- Reference Combinator -->
<div class="slide">
<header>
<h1>Removed from the specification</h1>
</header>
<section class="content">
<p>Reference combinator</p>
<pre><s>E /attr/ F</s></pre>
<pre><s>label /for/ input</s></pre>
</section>
</div>
<!-- Reference Combinator -->
<div class="slide">
<header>
<h1>Parent Selector</h1>
</header>
<p>Parent selector</p>
<pre><s>E! > F</s></pre>
<pre>:has</pre>
<p>Contains a header</p>
<pre>header:has(h1, h2, h3, h4, h5, h6)</pre>
<p>Contains no headers</p>