/
lesson1.html
1137 lines (821 loc) · 28 KB
/
lesson1.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 lang="en">
<head>
<meta charset="utf-8">
<title>Inside Browserland</title>
<meta name="description" content="Frontend (JavaScript, CSS and HTML) courses">
<meta name="author" content="Julien Muetton">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="reveal.js/css/reveal.min.css">
<link rel="stylesheet" href="css/theme/uda.css" id="theme">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="reveal.js/lib/css/zenburn.css">
<link rel="stylesheet" href="font-awesome/css/font-awesome.css" />
<!-- If the query includes 'print-pdf', use the PDF print sheet -->
<script>
document.write( '<link rel="stylesheet" href="reveal.js/css/print/' + ( window.location.search.match( /print-pdf/gi ) ? 'pdf' : 'paper' ) + '.css" type="text/css" media="print">' );
</script>
<!--[if lt IE 9]>
<script src="reveal.js/lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section class="cover">
<h1>Inside Browserland</h1>
<img src="img/01/html-sticker.png" class="cover-img" />
<p class="author">
<small>
By
<a href="">Julien Muetton</a>
/ <a href="https://twitter.com/themouette">@themouette</a>
</small>
</p>
<p class="given">
<small class="given-at"></small>
<small class="given-on"></small>
</p>
</section>
<section data-markdown data-separator="^\n---+\n---+\n$" data-vertical="^\n---+\n$" data-notes="^Note:" data-charset="utf-8"><script type="text/template">
### One might think this is love
<!-- .slide: data-background="img/01/browsers-ponies.png" data-background-size="100% auto" -->
<br /><br />
<br /><br />
<br /><br />
<br /><br />
<!-- .element: class="source" --> [image credits](http://paulirish.deviantart.com/art/My-Little-Browsers-307812128)
Note:
There is standards, so one might think: "Cool, let's do this"
---
---
### But reality is slightly different
<!-- .slide: data-background="img/01/browser-at-war.jpg" -->
<!-- .element: class="source" --> [image credits](http://www.ismartsoftware.com.au/the-wars-rise-again/)
Note:
But reality is a bit different...
</script></section>
<section data-markdown data-separator="^\n---+\n---+\n$" data-vertical="^\n---+\n$" data-notes="^Note:" data-charset="utf-8"><script type="text/template">
HTML
====
---
History
-------
* 1991: [Tim Berners-Lee](http://en.wikipedia.org/wiki/Tim_Berners-Lee) annonces Web creation on Usenet
* 1993: Mosaic and HTML enter the place (images and forms)
* 1994: Netscape styles the web (CSS and attributes)
* 1996: HTML 2 is the first standardized version
* 1999: HTML 4.1 Add frame and restrict allowed attributes
* 2001: XHTML 1.1 or Let the standard war begin
* 2007: HTML 5
<p class="fragment big" style="margin-top: 20px;">You should use <strong>HTML5</strong></p>
Note:
1993, HTML was not standardized, W3C draft was called HTML+
---
Definition
----------
> <span class="fragment highlight-current-red">**HyperText Markup
> Language**</span> is the <span class="fragment
> highlight-current-red">main</span> <span class="fragment
> highlight-current-red">markup language</span> for creating <span
> class="fragment highlight-current-red">web pages</span> and other information
> that can be displayed in a web browser.
>
> <!-- .element: class="source" --> [Wikipedia](http://en.wikipedia.org/wiki/HTML)
---
Sample
------
``` html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body class="theme">
<h1>Hello World</h1>
</body>
</html>
```
---
Doctype
-------
``` html
<!DOCTYPE html>
```
> A document type definition (DTD) is a set of markup declarations that define a
> document type for an SGML-family markup language (<accronym
> title="Standard Generalized Markup Language">SGML</accronym>, <accronym
> title="Extensible Markup Language">XML</accronym>, <accronym title="Hyper Text
> Markup Language">HTML</accronym>).
>
> <!-- .element: class="source" --> [Wikipedia](http://en.wikipedia.org/wiki/Document_type_definition)
---
Document
--------
Here is a typical document.
<div class="two-columns">
<pre style="width:48%"><code class="html"><html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
</body>
</html>
</code></pre>
<div style="width:48%">
<br />
<ul>
<li><span class="fragment highlight-current-green">`<html>`</span> element **is the page**;</li>
<li><span class="fragment highlight-current-green">`<head>`</span> is the page **metadata**;</li>
<li><span class="fragment highlight-current-green">`<body>`</span> is the page **content**.</li>
</ul>
</div>
</div>
---
Tag
---
<p class="big">
<<span class="fragment highlight-red" data-fragment-index="1">body</span> <span
class="fragment highlight-current-green" data-fragment-index="2"><span class="fragment
highlight-green" data-fragment-index="3">class</span>="<span class="fragment highlight-green" data-fragment-index="4">foo</span>"</span>>
<span class="fragment highlight-blue" data-fragment-index="5"></<span class="fragment highlight-red"
data-fragment-index="1">body</span>></span>
</p>
<p class="big" style="margin: 20px 0;">
<<span class="fragment highlight-red" data-fragment-index="1">i</span> <span
class="fragment highlight-current-green" data-fragment-index="2"><span class="fragment
highlight-green" data-fragment-index="3">class</span>="<span class="fragment highlight-green" data-fragment-index="4">foo</span>"</span> <span class="fragment highlight-blue" data-fragment-index="5">/</span>>
</p>
tagname <!-- .element: class="fragment" data-fragment-index="1" style="float: left; width: 25%; color: red; margin-top: 20px;" -->
attribute <!-- .element: class="fragment" data-fragment-index="2" style="float: left; width: 25%; color: green; margin-top: 20px;" -->
name <!-- .element: class="fragment" data-fragment-index="3" style="float: left; width: 25%;color: green; margin-top: 20px;" -->
and value <!-- .element: class="fragment" data-fragment-index="4" style="float: left; width: 25%;color: green; margin-top: 20px;"-->
<!-- .element: class="fragment" data-fragment-index="5" style="color: blue;margin-top: 120px;"--> closing is **optional**
<!-- .element: class="fragment" data-fragment-index="6" style="margin-top: 20px;"--> but explicit is **always** better than implicit
---
Syntax
------
<pre class="green"><code class="html">
<em>I <strong>really</strong> mean that</em>.
</code></pre>
<p><em>I <strong>really</strong> mean that</em>.</p>
<pre class="red"><code class="html">
<em>Invalid: I <strong>really</em> mean that</strong>.
</code></pre>
---
Metadata tags
-------------
* `<title>` Defines the title of the document, shown in a browser's title bar or on
the page's tab.
* `<link>` Used to link JavaScript and external CSS with the current HTML document.
* `<meta>` Defines metadata that can't be defined using another HTML element.
* `<style>` Used to write inline CSS.
> <!-- .element: class="source" --> [<accronym title="Mozilla Developer
> Network">MDN</accronym>](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/HTML5_element_list)
---
Script tags
-----------
* `<script>` Defines either an internal script or a link to an external script.
The script language is JavaScript.
* `<noscript>` Defines alternative content to display when the browser doesn't
support scripting.
> <!-- .element: class="source" --> [<accronym title="Mozilla Developer
> Network">MDN</accronym>](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/HTML5_element_list)
---
Meaningless tags
----------------
Elements `div` and `span` are available for style. They have no semantic meaning.
``` html
<div>
Hello I'm a <span>span</span> in a div.
</div>
```
> <div>
> Hello I'm a <span>span</span> in a div.
> </div>
Use them for style purpose.
---
Text
----
``` html
<p>
Something <strong>very</strong> <em>important</em>
<accronym title="To Me">2M</accronyme>
</p>
```
> <p>
> Something <strong>very</strong> <em>important</em>
> <accronym title="To Me">2M</accronyme>
> </p>
More with `<address>`, `<small>`, `<h1>`, `<h2>`, `<blockquote>`...
---
Tables
------
<!-- .slide: class="html-demo" -->
> <table>
> <thead>
> <tr><th>title 1</th><th>title 2</th></tr>
> </thead>
> <tfoot>
> <tr><td colspan="2">I'm the footer</td></tr>
> </tfoot>
> <tbody>
> <tr><td>value</td><td>value</td></tr>
> <tr><td>value</td><td>value</td></tr>
> </tbody>
> </table>
``` html
<table>
<thead>
<tr><th>title 1</th><th>title 2</th></tr>
</thead>
<tfoot>
<tr><td colspan="2">I'm the footer</td></tr>
</tfoot>
<tbody>
<tr><td>value</td><td>value</td></tr>
<tr><td>value</td><td>value</td></tr>
</tbody>
</table>
```
---
Lists
-----
<!-- .slide: class="html-demo lists" -->
<div class="three-columns">
<div class="fragment" data-fragment-index="1">
<ul>
<li>lorem ipsum</li>
</ul>
</div>
<div class="fragment" data-fragment-index="2">
<ol>
<li>lorem ipsum</li>
</ol>
</div>
<div class="fragment" data-fragment-index="3">
<dl>
<dt>title</dt>
<dd>definition</dd>
</dl>
</div>
</div>
<div class="three-columns">
<h4 class="fragment" data-fragment-index="1">Unordered list</h4>
<h4 class="fragment" data-fragment-index="2">Ordered list</h4>
<h4 class="fragment" data-fragment-index="3">Definition list</h4>
</div>
<div class="three-columns">
<pre class="fragment" data-fragment-index="1"><code class="html"><ul>
<li>lorem</li>
</ul>
</code></pre>
<pre class="fragment" data-fragment-index="2"><code class="html"><ol>
<li>lorem</li>
</ol>
</code></pre>
<pre class="fragment" data-fragment-index="3"><code class="html"><dl>
<dt>title</dt>
<dd>definition</dd>
</dl>
</code></pre>
</div>
---
Forms
-----
<!-- .slide: class="html-demo html-forms" -->
> <form method="POST" action="/banana" enctype="multipart/form-data">
> <p>
> <label>Name: <input type="text" name="name" /></label>
> <label>
> Color: <input type="color" name="color" value="#D8DE26" />
> </label>
> </p>
>
> <p>
> <label for="color">Avatar:</label>
> <span><input type="file" name="avatar" /></span>
> <input type="button" value="Create" />
> </p>
> </form>
``` html
<form method="POST" action="/banana" enctype="multipart/form-data">
<p>
<label>Name: <input type="text" name="name" /></label>
<label>
Color: <input type="color" name="color" value="#D8DE26" />
</label>
</p>
<p>
<label>Avatar: <input type="file" name="avatar" /></label>
<input type="button" value="Create" />
</p>
</form>
```
---
Links
-----
<!-- .slide: class="html-demo" -->
> Find the slides on <a href="https://github.com/themouette/slides-edu-frontend">github</a>.
``` html
Find the slides on
<a href="https://github.com/themouette/slides-edu-frontend">
github
</a>.
```
</script></section>
<section data-markdown data-separator="^\n---+\n---+\n$" data-vertical="^\n---+\n$" data-notes="^Note:" data-charset="utf-8"><script type="text/template">
DOM
===
<img src="img/01/dom-tree.png" style="height: 350px;"/>
<!-- .element: class="source" --> [image credits](http://www.annuairedubusiness.com/blog/internet-et-ses-secrets/4-html-elements.html)
---
Document Object Model
---------------------
> A cross-platform and language-independent convention for representing and
> interacting with objects in HTML, XHTML and XML documents.
>
> <!-- .element: class="source" --> [Wikipedia](http://en.wikipedia.org/wiki/Document_Object_Model)
[What is the DOM](http://css-tricks.com/dom/) from [css-tricks](http://css-tricks.com)
---
From HTML to DOM
----------------
<div class="two-columns">
<pre><code class="html"><!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<h1>Hello world !</h1>
<p>som content.</p>
</body>
</html>
</code></pre>
<div>
<img src="img/01/rendered-dom-tree.png"
</div>
</div>
---
Document, window and elements
-----------------------------
<img src="img/01/DOM-3D.png" style="height: 350px;"/>
---
DOM standardized API
--------------------
Basicly a set of interfaces:
[HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement) inherits from [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element) inherits form [Node](https://developer.mozilla.org/en-US/docs/Web/API/Node)
[Complete reference](https://developer.mozilla.org/en-US/docs/DOM)
---
Retreiving Elements
-------------------
* getElementById
* getElementsByTagName
* querySelector
* querySelectorAll
---
<!-- .slide: id="getElementById" class="dom-example" -->
ById and ByTagname
------------------
<br />
<pre><code class="javascript runnable" data-runnable-output="console">document.getElementById('getElementById');</code></pre>
<br />
<pre><code class="javascript runnable" data-runnable-output="console">document.getElementsByTagName('pre');</code></pre>
<br />
<p class="alert info">Open your browser console to see examples in action.</p>
---
<!-- .slide: id="querySelector" class="dom-example" -->
By css selector
---------------
<br />
<pre><code class="javascript runnable" data-runnable-output="console">document.querySelector('#querySelector pre');</code></pre>
<br />
<pre><code class="javascript runnable" data-runnable-output="console">document.querySelectorAll('#querySelector pre');</code></pre>
<br />
<p class="alert info">Open your browser console to see examples in action.</p>
---
Tree Traversal
--------------
* `parentElement`
* `childNodes`
* `children`
* `firstChild`
* `lastChild`
---
<!-- .slide: id="DOM-traversal" class="dom-example" -->
Play with tree traversal
------------------------
<br />
<div class="two-columns">
<div class="example" style="width:25%"><p>item 0</p><p>item 1</p><p>item 2</p><p>item 3</p><p>item 4</p></div>
<pre style="width:71%"><code class="javascript runnable">var element = document
.querySelector('#DOM-traversal .example');
element.firstChild.style.color = "red";
element.childNodes.item(1)
.style.border = "3px solid green";
element.lastChild.style.background = "blue";
</code></pre>
</div>
<br />
Note:
childNodes is a [NodeList](https://developer.mozilla.org/en-US/docs/Web/API/NodeList)
---
Tree Insertion
--------------
<br />
[**appendChild**](https://developer.mozilla.org/en-US/docs/Web/API/Node.appendChild) to insert at last position:
``` javascript
var child = element.appendChild(child);
```
<br />
[**insertBefore**](https://developer.mozilla.org/en-US/docs/Web/API/Node.insertBefore) to insert before an existing child:
``` javascript
var insertedElement = parentElement.insertBefore(newElement, referenceElement);
```
---
Tree Removal
------------
[**removeChild**](https://developer.mozilla.org/en-US/docs/Web/API/Node.removeChild) to remove an existing child:
``` javascript
var oldChild = element.removeChild(child);
```
---
<!-- .slide: class="no-transform" -->
EventTarget Interface
---------------------
[**addEventListener**](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget.addEventListener)
``` javascript
e.addEventListener('name', callback[, useCapture]);
```
[**removeEventListener**](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget.removeEventListener)
``` javascript
e.removeEventListener('name', callback[, useCapture]);
```
[**dispatchEvent**](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget.dispatchEvent)
``` javascript
element.dispatchEvent('name');
```
<p class="alert warn">Prior to IE8 (IE <= 8), use `detachEvent` and `attachEvent`.</p>
Note:
useCapture:
If true, useCapture indicates that the user wishes to initiate capture. After
initiating capture, all events of the specified type will be dispatched to the
registered listener before being dispatched to any EventTarget beneath it in the
DOM tree. Events which are bubbling upward through the tree will not trigger a
listener designated to use capture. See DOM Level 3 Events for a detailed
explanation. If not specified, useCapture defaults to false.
---
Common APIs
-----------
* [innerHTML](https://developer.mozilla.org/en-US/docs/Web/API/Element.innerHTML)
* addClassName
* [style](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Properties_Reference)
* getAttribute
* ...
---
Going further on Browser rendering
----------------------------------
Watch with subtitles:
<iframe width="420" height="315"
src="//www.youtube.com/embed/a2_6bGNZ7bA?rel=0&cc_load_policy=1"
frameborder="0" allowfullscreen></iframe>
And also [How Browsers Work by Tali Garsiel](http://taligarsiel.com/Projects/howbrowserswork1.htm)
---
Going further on Browser performances
-------------------------------------
<iframe src="//player.vimeo.com/video/67050197" width="500" height="281"
frameborder="0" webkitallowfullscreen mozallowfullscreen
allowfullscreen></iframe>
[Rendering without lumpy bits - Jake Archibald - Front-Trends 2013](http://vimeo.com/67050197)
from [Front-Trends](http://vimeo.com/fronttrends)
</script></section>
<section data-markdown data-separator="^\n---+\n---+\n$" data-vertical="^\n---+\n$" data-notes="^Note:" data-charset="utf-8"><script type="text/template">
HTML5
-----
<!-- .slide: data-background="img/01/html5logo.svg" data-background-size="auto 70%" class="hide-title" -->
---
References
----------
* [tags and attributes](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/HTML5_element_list)
* [All input types](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input)
---
Forms
-----
-----
Input type="range"
------------------
<!-- .slide: class="html-demo" -->
> <form oninput="result.value=parseInt(a.value)">
> <p>
> <label>Range: <input type="range" min="10" max="30" name="a" value="10" /></label>
> <output name="result">10</output>
> </p>
> </form>
``` html
<label>
Range:
<input type="range" min="10" max="30" name="a" />
</label>
```
---
Input type="color"
------------------
<!-- .slide: class="html-demo" -->
> <form oninput="result.value=a.value">
> <p>
> <label>Color: <input type="color" name="a" value="#cacaca" /></label>
> <output name="result">#cacaca</output>
> </p>
> </form>
``` html
<label>
Color:
<input type="color" name="a" value="#cacaca" />
</label>
```
---
Input type="number"
------------------
<!-- .slide: class="html-demo" -->
> <form>
> <p>
> <label>Number: <input type="number" name="a" value="12" /></label>
> </p>
> </form>
``` html
<label>
Number:
<input type="number" name="a" />
</label>
```
---
Input type="date"
------------------
<!-- .slide: class="html-demo" -->
> <form>
> <p>
> <label>When? <input type="date" name="a" /></label>
> </p>
> </form>
``` html
<label>
When?
<input type="date" name="a" />
</label>
```
---
Textual inputs
--------------
<!-- .slide: class="html-demo" -->
> <form>
> <p>
> <label>type="phone": <input type="tel" name="a" /></label>
> </p>
> <p>
> <label>type="email": <input type="email" name="b" class="validate" /></label>
> </p>
> <p>
> <label>type="url": <input type="url" name="c" class="validate" /></label>
> </p>
> <p>
> <label>type="search": <input type="search" name="d" /></label>
> </p>
> </form>
---
Placeholder
-----------
<!-- .slide: class="html-demo" -->
> <form>
> <p>
> <label>Email <input type="email" placeholder="foo@example.com" /></label>
> </p>
> </form>
``` html
<label>
Email
<input type="email" placeholder="foo@example.com" />
</label>
```
---
Form Validation
---------------
<!-- .slide: class="html-demo validate" -->
> <form>
> <p>
> <label>
> Enter 1-3 numbers
> <input type="text" pattern="^\d{1,3}$" class="validate" required />
> </label>
> </p>
> </form>
``` html
<label>
Enter 1-3 numbers
<input type="text" pattern="^\d{1,3}$" class="validate" required />
</label>
```
---
Form Submission
---------------
On a submit button:
* `formnovalidate`: submit event invalid forms
* `formaction`: Replaces form action
* `formmethod`: Replaces form method
---
Layout
------
<div class="two-columns">
* [Learnlayout](http://learnlayout.com/) by [bocoup](http://bocoup.com/)
* [HTML5 layout from scratch](http://coding.smashingmagazine.com/2009/08/04/designing-a-html-5-layout-from-scratch/)
</div>
![Typical html5 layout](img/01/html5pagelayout.png)
> <!-- .element: class="source" --> Image is courtesy of [Modesty Zhang](http://www.codeproject.com/Articles/146409/Semantic-HTML5-Page-Layout)
Note:
`<section>` Defines a section in a document.
`<nav>` Defines a section that contains only navigation links.
`<article>` Defines self-contained content that could exist independently of the rest of the content.
`<aside>` Defines some content loosely related to the page content. If it is removed, the remaining content still makes sense.
`<header>` Defines the header of a page or section. It often contains a logo, the title of the Web site, and a navigational table of content.
`<footer>` Defines the footer for a page or section. It often contains a copyright notice, some links to legal information, or addresses to give feedback.
`<main>` Defines the main or important content in the document. There is only one `<main>` element in the document.
---
Content
-------
img, video, audio, canvas...
</script></section>
<section data-markdown data-separator="^\n---+\n---+\n$" data-vertical="^\n---+\n$" data-notes="^Note:" data-charset="utf-8"><script type="text/template">
Css selectors
=============
<img src="img/01/logo_css3.png" style="height: 350px; padding: 20px;" />
---
Cascading StyleSheet
--------------------
* [CSS 2.1 Selector specifications](http://www.w3.org/TR/CSS2/selector.html)
* [CSS 3 Selector specifications](http://www.w3.org/TR/css3-selectors/)
---
TagName selector
----------------
<div class="two-columns">
<div style="width: 30%">
<p>**Try this:**</p><br />
<ul>
<li>**`*`**</dd>
<li>**`div`**</li>
<li>**`div p`**</li>
</ul>
</div>
<div class="dom-match" style="width: 66%">
<div>
<p></p>
</div>
<p></p>
</div>
</div>
---
\#id
---
<div class="two-columns">
<div style="width: 30%">
<p>**Try this:**</p><br />
<ul>
<li>**`#foo`**</dd>
<li>**`div#foo`**</li>
<li>**`p#foo`**</li>
</ul>
</div>
<div class="dom-match" style="width: 66%">
<div>
<p id="foo"></p>
</div>
<p></p>
</div>
</div>
---
.classname
----------
<div class="two-columns">
<div style="width: 30%">
<p>**Try this:**</p><br />
<ul>
<li>**`.foo`**</dd>
<li>**`div.foo`**</li>
<li>**`p.foo`**</li>
</ul>
</div>
<div class="dom-match" style="width: 66%">
<div class="foo">
<p></p>
</div>
<p class="foo"></p>
</div>
</div>
---
[attr=value]
------------
<div class="two-columns">
<div style="width: 30%">
<p>**Try this:**</p><br />