-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsession2.html
More file actions
1628 lines (1457 loc) · 69.2 KB
/
session2.html
File metadata and controls
1628 lines (1457 loc) · 69.2 KB
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>Session 2 — HTML/CSS — Girl Develop It</title>
<meta name="description" content="This is the official Girl Develop It Core HTML/CSS curriculum. It was developed through the contributions of Pamela Fox, Alexis Goldstein, Erin M. Kidwell, Izzy Johnston, Jen Myers, Cara Jo Miller, Laura Eagin, Nicole Rodriguez, and Leeann Drees.
The course is meant to be taught in 2 four-hour sections. Each of the slides and practice files are customizable according to the needs of a given class or audience.">
<meta name="author" content="Girl Develop It">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<link rel="stylesheet" href="css/reveal.min.css">
<link rel="stylesheet" href="css/theme/gdiaa.css" id="theme">
<link rel="stylesheet" href="lib/css/light.css">
<link rel="stylesheet" href="css/print/pdf.css" media="print">
<script src="lib/js/head.min.js"></script>
<!--[if lt IE 9]>
<script src="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">
<!-- INTRO -->
<section>
<!-- WiFi Info -->
<section>
<h3>Set Up for Today</h3>
<div class="box right" style="width: 35%;">
<img src="images/folderstructure3.jpg" style="border:none; box-shadow: none; width:75%;"/>
</div>
<div class="box left" style="width: 60%;">
<ul class="list--tall copy--small">
<li>Create your <span class="green">html-site2</span> folder if you haven't already.</li>
<li>Inside <span class="green">html-site2</span>, create <span class="blue">index.html</span>, <span class="blue">styles.css</span>, and an <span class="green">images</span> folder.</li>
<li>Download the icons <a href="assets/icons.zip">here</a></li>
</ul>
</div>
</section>
<!-- Title -->
<section>
<img src="images/gdi_logo_badge.png" class="img--bare" height="450px" />
<div class="box--small">
<h3><span class="green">Beginning HTML and CSS</span></h3>
<h4><span class="blue">Session 2</span></h4>
</div>
</section>
</section>
<!-- REVIEW & SETUP -->
<section>
<!-- Roles of HTML v CSS -->
<section>
<h3>Anatomy of a Website</h3>
<div class="blue box--small copy--small" style="float: left; width: 33.333%;">
<p>Content</p>
<img src="images/example_site_content.jpg" alt="Example of site content" />
</div>
<div class="box--small copy--small" style="float: left; width: 33.333%;">
<p><span class="green">+ HTML</span> (Structure)</p>
<img src="images/example_site_HTML.jpg" alt="Example of site structure" />
</div>
<div class="box--small copy--small" style="float: left; width: 33.333%;">
<p><span class="red">+ CSS</span> (Presentation)</p>
<img src="images/example_site_HTML_CSS.jpg" alt="Example of site with CSS" />
</div>
</section>
<!--anatomy of a tag -->
<section>
<h3>Review: Tag Breakdown</h3>
<img src="images/tagbreakdown.png" alt="Tag breakdown" style="border: none; box-shadow: none; height: 600px;" />
</section>
<!-- The CSS Rule-->
<section>
<h3>Review: The CSS Rule</h3>
<img src="images/cssrule.png" alt="The CSS Rule" class="box--small" style="border: none; box-shadow: none;"/>
</section>
<!-- <section>
<h3>Block & Inline Elements</h3>
<ul class="box--small list--tall copy--small">
<li>CSS divides HTML into two types: inline and block.</li>
<li>After block elements, browsers render a new line.</li>
<li>Inline elements: img, a, br, em, strong</li>
<li>Block elements: p, h1, ul, li, almost everything else</li>
</ul>
</section> -->
<section>
<h3>What's wrong with my code?</h3>
<p class="copy--small box--small">Why do you think this code isn't working?</p>
<div>
<p class="red left-align">WRONG:</p>
<pre style="height: 40px; overflow:hidden"><code>
<a href="http://google.com" Google</a>
</code></pre>
</div>
<div class="box--small fragment">
<p class="green left-align">CORRECT:</p>
<pre style="height: 40px; overflow:hidden"><code>
<a href="http://google.com">Google</a>
</code></pre>
<p><small>Don't forget to wrap your tags with <code><</code> <code>></code>.</small></p>
</div>
</section>
<section>
<h3>What's wrong with my code?</h3>
<p class="copy--small box--small">Why do you think this code isn't working?</p>
<div>
<p class="red left-align">WRONG:</p>
<pre style="height: 40px; overflow:hidden"><code>
<link rel=stylesheet" href="styles.css >
</code></pre>
</div>
<div class="box--small fragment">
<p class="green left-align">CORRECT:</p>
<pre style="height: 40px; overflow:hidden"><code>
<link rel="stylesheet" href="styles.css" />
</code></pre>
<p><small>Don't forget to quote parameter values.</small></p>
<p><small>Don't forget to close self-closing tags.</small></p>
</div>
</section>
<section>
<h3>What's wrong with my code?</h3>
<p class="copy--small box--small">Why do you think this code isn't working?</p>
<div>
<p class="red left-align">WRONG:</p>
<pre style="height: 120px; overflow:hidden"><code>
p
background-color: red
color: #eee
}
</code></pre>
</div>
<div class="box--small fragment">
<p class="green left-align">CORRECT:</p>
<pre style="height: 120px; overflow:hidden"><code>
p {
background-color: red;
color: #eee;
} </code></pre>
<p><small>Don't forget to put curly braces around your declarations.</small></p>
<p><small>Don't forget your semi-colons.</small></p>
</div>
</section>
<section>
<h3>Homework: Inspecting Elements</h3>
<p class="copy--small box--small">Let's right-click, "Inspect Element" & look at some code!</p>
<a href="http://alistapart.com" target="_blank"><img src="images/ala.png" alt="A List Apart homepage" target="_blank" height="350px"/></a>
<a href="http://tattly.com" target="_blank"><img src="images/tattly.png" alt="Tattly homepage" target="_blank" height="350px"/></a>
</section>
<section>
<h3>What we'll be making today</h3>
<p class="copy--small box--small">Today we will be making a site from scratch using HTML5 elements to create a header, footer, sidebar and a content area.</p>
<p class="copy--small">Then we'll add CSS styles to make it pretty*!</p>
<img class="box--small" src="images/making-this-today-2.png" width="500px">
<div><small>* prettiness not guaranteed</small></div>
</section>
<!-- Folder Structure -->
<section>
<h3>Folder Structure</h3>
<div class="left box--small" style="width: 48%;">
<p class="left-align"><strong>Do you have your folder set up yet?</strong></p><br />
<ul class="copy--small list--tall">
<li>Name it <span class="blue">html-site2</span></li>
<li>Create new <span class="green">index.html</span> and <span class="green">styles.css</span> files.
<li>Create an <span class="blue">images</span> folder <small>(lowercase)</small></li>
<li>Drop your image files into the images folder.</li>
</ul>
</div>
<div class="right box" style="width: 45%;">
<img src="images/folderstructure3.jpg" style="border:none; box-shadow: none;"/>
</div>
</section>
<section>
<h3>Wait...why <span class="green">index.html?</span></h3>
<div class="box--small">
<ul class=" copy--small list--tall">
<li class="fragment"><span class="green">index.html</span> is the default filename a web browser looks for when pointed to any directory.</li>
<li class="fragment">You won't necessarily see it reflected in the URL — we just see <span class="pink">http://girldevelopit.com</span>, but the browser is displaying <span class="pink">http://girldevelopit.com/index.html</span>. Sneaky!</li>
<li class="fragment">You should have an <span class="green">index.html</span> file for every directory on your site. If not, users will see a list of all your filenames, like this:
<p class="center-align box--small"><img src="images/noindex.png" /></p>
</li>
</ul>
<small class="fragment"><b>Side Note:</b> You can name your CSS stylesheets whatever you want. <br/>Common choices: <code>application.css</code>, <code>styles.css</code>, <code>style.css</code>, <code>main.css</code></small>
</div>
</section>
<section>
<h3>Let's Develop It</h3>
<p class="box--small">Setting up our <span class="green">index</span> file for today...</p>
<ul class="list--tall copy--small">
<li>Open your new <span class="green">index.html</span> file</li>
<li>Remember to start with <code>doctype</code> & <code>html</code> tags.</li>
<li>Add the code to link to <span class="green">styles.css</span>!</li>
</ul>
<pre><code class="html" style="min-height: 300px; max-height: 475px;">
<!DOCTYPE html>
<html>
<head>
<title>Title of the page </title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
</body>
</html>
</code></pre>
</section>
</section>
<!-- Structural Elements -->
<section>
<section>
<h3>Structural Elements!</h3>
<p class="copy--small box--small">Structuring our content, creating layout</p>
<div class="left" style="width: 35%;">
<p class="box--small">Example:</p>
<ul>
<li class="yellow">Header</li>
<li class="pink">Main</li>
<li class="blue">Aside</li>
</ul>
</div>
<div class="right" style="width: 50%;">
<img src="images/html5_structure.jpg" style="border:none; box-shadow: none;"/>
</div>
</section>
<section>
<h3>Structural Elements!</h3>
<a href="http://girldevelopit.com/chapters/detroit" target="_blank"><img src="images/gdisite-html5.jpg"></a>
</section>
<!-- Header -->
<section>
<h3>HTML5 Element: <span class="yellow"><header></span></h3>
<ul class="copy--small list--tall box--small">
<li>Container for a group of introductory or navigational aids</li>
<li>Document can have multiple header elements</li>
<li>E.g. One for the page, one for each section</li>
</ul>
<pre><code class="html">
<header>
<a href="/"><img src="site-logo.png" /></a>
<nav>
<ul>
<li>Your menu</li>
</ul>
</nav>
</header>
</code></pre>
</section>
<!-- Footer -->
<section>
<h3>HTML5 Element: <span class="yellow"><footer></span></h3>
<ul class="copy--small list--tall box--small">
<li>Contains information about its containing element</li>
<li>E.g. who wrote it, copyright, links to related content, etc.</li>
<li>Document can have multiple footer elements</li>
<li>E.g. One for the page, one for each section</li>
</ul>
<pre style="height: 80px; overflow: hidden;"><code class="html">
<footer>
<p>©2014 Girl Develop It. Super fancy codes written by Julie, Nicole and Leeann.</p>
</footer>
</code></pre>
</section>
<!-- Main -->
<section>
<h3>HTML5 Element: <span class="yellow"><main></span></h3>
<ul class="copy--small list--tall box--small">
<li>Use once per page to mark where main content begins</li>
<li>Helpful for screen readers/assistive technology, content syndication, and mobile browsers</li>
</ul>
<pre><code class="html">
<main>
<h1>Web Browsers</h1>
<p>Google Chrome, Firefox, and Internet Explorer are the most used browsers today.</p>
<article>
<h1>Google Chrome</h1>
<p>Google Chrome is a free, open-source web browser developed by Google.</p>
</article>
<article>
<h1>Mozilla Firefox</h1>
<p>Firefox is a free, open-source web browser from Mozilla.</p>
</article>
</main>
</code></pre>
</section>
<!--<section>
<h3>HTML5 Element: <span class="yellow"><section></span></h3>
<ul>
<li>Group together thematically related content</li>
<li>Similar to prior use of the div, but div has no semantic meaning</li>
</ul>
</section> -->
<!-- Aside -->
<section>
<h3>HTML5 Element: <span class="yellow"><aside></span></h3>
<ul class="copy--small box--small list--tall">
<li>Tangentially related content</li>
<li>E.g. sidebar, pull quotes</li>
</ul>
<p class="copy--small"><strong>Ask yourself:</strong><br/>Can the content within the aside be removed without<br/> reducing the meaning of the main content?</p>
<pre style="height: 200px; overflow: hidden;"><code class="html">
<main>
<p>My family and I visited The Epcot center this summer.</p>
<aside>
<h4>Epcot Center</h4>
<p>The Epcot Center is a theme park in Disney World, Florida.</p>
</aside>
</main>
</code></pre>
</section>
<!-- Nav -->
<section>
<h3>HTML5 Element: <span class="yellow"><nav></span></h3>
<ul class="copy--small list--tall box--small">
<li>Contains major navigational information</li>
<li>Usually a list of links</li>
<li>Often lives in the header</li>
<li>E.g. site navigation</li>
</ul>
<pre><code class="html">
<nav>
<ul>
<li>Menu Link 1</li>
<li>Menu Link 2</li>
</ul>
</nav>
</code></pre>
</section>
<!--<section>
<h3>HTML5 Element: <span class="yellow"><article></span></h3>
<ul>
<li>Self-contained related content</li>
<li>E.g. blog posts, news stories, comments, reviews, forum posts</li>
</ul>
</section>-->
<!-- Exercise -->
<section>
<h3>Let's Develop It</h3>
<p class=" box--small copy--small">Inside <code>body</code>, create the following structure:</p>
<ul class="list--tall copy--xsmall">
<li>A header</li>
<li>A main content area</li>
<li>A sidebar (aside)</li>
<li>A footer</li>
</ul>
<pre><code class="html" style="min-height: 250px; max-height: 250px;">
<header>
</header>
<main>
</main>
<aside>
</aside>
<footer>
</footer>
</code></pre>
</section>
<section>
<h3>Check-in</h3>
<p class="copy--small box--small">Now your <span class="blue">index.html</span> file should have the following structure:</p>
<pre><code class="html">
<!doctype html>
<html>
<head>
<title></title>
</head>
<body>
<header>
</header>
<main>
</main>
<aside>
</aside>
<footer>
</footer>
</body>
</html>
</code></pre>
</section>
<!-- Adding Content -->
<section>
<h3>Let's Develop It</h3>
<p class="box--small">Begin filling in content</p>
<ul class="copy--small list--tall box--small ">
<li>Inside <code>header</code>, add your page's title as a <code>h1</code></li>
<li>Add a few paragraphs & headings to <code>main</code></li>
<li>Add a profile image to <code>aside</code></li>
<li>Add a sentence to <code>footer</code></li>
</ul>
<pre style="height: 40px; overflow: hidden;"><code class="html">
<img src="images/profile.jpg" alt="my profile pic" width="200"/>
</code></pre>
</section>
<section>
<h3>Add a list and links</h3>
<ul class="copy--small box--small list--tall">
<li>Add a list to the sidebar</li>
<li>Add several links</li>
</ul>
<pre><code class="html">
<a href="http://girldevelopit.com" target="_blank"/>My Link</a>
<ul>
<li>List Item</li>
<li>Another List Item</li>
<li>Another List Item</li>
<li><a href="http://girldevelopit.com" target="_blank"/>My Link</a></li>
<li>Another List Item</li>
</ul>
</code></pre>
</section>
</section>
<!-- Box Model -->
<section>
<!-- Inline vs. block-->
<section>
<h3>Inline vs Block</h3>
<div class="left copy--small" style="width: 50%; text-align: left;">
<div class="box--small fragment">
<p>So far, we have mostly seen <span class="green">"block"</span> elements.</p>
<ul>
<li>They render on new lines, ie. paragraphs.</li>
<li><span class="green">Block elements</span>: <code>p</code>, <code>h1</code>, <code>ul</code>, <code>li</code>, almost everything else</li>
</ul>
</div>
<div class="fragment">
<p>There are also <span class="green">"inline"</span> elements</p>
<ul>
<li>They render on the same line that they are written on.</li>
<li><span class="green">Inline elements</span>: <code>img</code>, <code>a</code>, <code>br</code>, <code>em</code>, <code>strong</code></li>
</ul>
</div>
</div>
<div class="box--small right fragment">
<img src="images/example-blockinline.png" alt="example of inline and block elements" />
</div>
</section>
<!-- Box model-->
<section>
<h3>Box Model</h3>
<div class="box left-align copy--xsmall" style="width:30%; float:left;">
<p>The CSS box model is essentially a box that wraps around HTML elements, and consists of: margins, borders, padding, and the actual content.</p>
<p class="box--small">The box model allows us to place a border around elements and space elements in relation to other elements.</p>
<small>Definition from <a href="https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CCgQhi0wAA&url=http%3A%2F%2Fwww.w3schools.com%2Fcss%2Fcss_boxmodel.asp&ei=eEsrU6_mCcuuqQGmt4HgCg&usg=AFQjCNEDIKDFEnu59p1akFM5Hk9scACuKQ&sig2=xCrX7kFEUSukjWNosFs62g&bvm=bv.62922401,d.aWM">w3schools</a></small>
</div>
<div class="box--small" style="width:65%; float:right;"><img src="images/box-model.png" style="border:none;"/></div>
</section>
<section>
<h3>Alternate Box Model</h3>
<img src="images/box_model_cat.jpg" width="650"/>
</section>
</section>
<!-- Border -->
<section>
<!-- Border-->
<section>
<h3>Border</h3>
<p class="copy--small box--small">The edge around the box that we can style with CSS</p>
<img src="images/box-model-border.png" width="650" style="border: 0;">
</section>
<section>
<h3>Border</h3>
<p class="copy--small box--small">Border is specified in "thickness, style, color."</p>
<p class="copy--xsmall box--small">A solid red border</p>
<pre style="height: 80px; overflow: hidden"><code class="css">
.normal {
border: 1px solid #ff0000;
}
</code></pre><br/>
<p class="copy--xsmall box--small">A thick dotted black top border</p>
<pre style="height: 80px; overflow: hidden"><code class="css">
.thick {
border-top: 4px dotted #000000;
}
</code></pre>
</section>
<section>
<h3>Border</h3>
<p class="box--small copy--small">Two different border styles</p>
<pre><code class="css">
.woah {
border-top: 1px solid #ff0000;
border-bottom: 4px dotted #000000;
}
</code></pre>
</section>
<section>
<h3>Fun With Borders</h3>
<p class="copy--small box--small">You can specify each property separately,<br/>or all three together (as "shorthand").</p>
<pre><code class="css">
.another_border {
border-width: 10px;
border-style: dashed;
border-color: #666666;
}
.some_border {
border: 10px dashed #666666;
}
</code></pre>
</section>
<!-- Exercise -->
<section>
<h3>Let's Develop it!</h3>
<p class="copy--small box--small">Let's add borders to our elements.</p>
<pre><code class="css">
main {
border: 1px solid #ff0000;
}
header {
border-bottom: 4px dotted #000000;
}
aside {
border-top: 1px solid orange;
border-bottom: 4px dotted #000000;
}
</code></pre>
</section>
</section>
<!-- Padding -->
<section>
<!-- Padding -->
<section>
<h3>Padding</h3>
<p class="copy--small box--small">Space between the border and the content</p>
<p class="copy--small box--small">Adds to the total width of the box.</p>
<img src="images/box-model-padding.png" width="600" style="border:none;"/>
</section>
<section>
<h3>Padding (all sides)</h3>
<p class="copy--small box--small">15 pixels on all sides</p>
<pre style="height: 40px; overflow: hidden;"><code class="css">
padding: 15px;
</code></pre><br/>
<h3>Padding Top</h3>
<p class="copy--small box--small">10 pixels on top only</p>
<pre style="height: 40px; overflow: hidden;"><code class="css">
padding-top: 10px;
</code></pre>
</section>
<section>
<h4>One Value</h4>
<pre style="height: 80px; overflow: hidden;"><code class="css">
.all_sides{
padding: 15px;
}
</code></pre><br/>
<h4>Two Values</h4>
<pre style="height: 80px; overflow: hidden;"><code class="css">
.topANDbottom_rightANDleft {
padding: 10px 5px;
}
</code></pre><br/>
<h4>Multiple Values</h4>
<pre style="height: 80px; overflow: hidden;"><code class="css">
.top_right_bottom_left {
padding: 10px 5px 3px 5px;
}
</code></pre>
</section>
<section>
<h3>Padding</h3>
<img src="images/box-model-padding2.png" width="650"/>
</section>
<!-- Exercise -->
<section>
<h3>Let's Develop it!</h3>
<p class="box--small copy--small">In <span class="green">styles.css</span>, let's add some padding to our elements.</p>
<pre style="height: 40px; overflow: hidden;"><code class="css">
padding: 10px;
</code></pre>
<pre style="height: 40px; overflow: hidden;"><code class="css">
padding: 10px 20px 30px 40px;
</code></pre>
</section>
</section>
<!-- Margin -->
<section>
<!-- Margin -->
<section>
<h3>Margin</h3>
<p class="copy--small box--small">The transparent area around the box that<br/>separates it from other elements.</p>
<img src="images/box-model-margin.png" width="650"/>
</section>
<section>
<h3>Margin</h3>
<p class="box--small copy--small">15 pixels on all sides</p>
<pre style="height: 40px; overflow: hidden;"><code class="css">
margin: 15px;
</code></pre>
<p class="box--small copy--small">10 on top, 5 on right, 3 on bottom, 5 on left</p>
<pre style="height: 40px; overflow: hidden;"><code class="css">
margin: 10px 5px 3px 5px;
</code></pre>
<p class="box--small copy--small">10 pixels on top</p>
<pre style="height: 40px; overflow: hidden;"><code class="css">
margin-top: 10px;
</code></pre>
</section>
<section>
<h3>Auto Margins</h3>
<p class="box--small copy--small">If a block-level element <em>has a set width</em>, you can set the left and right margins to <code>auto</code> to horizontally center the element in the container.</p>
<pre style="height: 120px; overflow: hidden"><code class="html">
p {
margin: 0 auto;
width: 500px;
}
</code></pre>
<p class="copy--xsmall left-align box--small" style="width: 500px; margin: 20px auto;">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat.</p>
</section>
<!-- Exercise -->
<section>
<h3>Let's Develop it!</h3>
<p class="copy--small box">Let's center our entire page in the browser<br />via width + auto margins.</p>
<p class="copy--small">Let's add some margins to our other elements.</p>
</section>
<section>
<h3>Check-in</h3>
<p class="copy--small box--small">You should now have some rules like these:</p>
<pre><code class="css">
header, footer, aside {
margin: 10px;
padding: 5px;
}
body {
margin: auto;
width: 800px;
}
</code></pre>
</section>
</section>
<!-- Width & Height -->
<section>
<!-- Width-->
<section>
<h3>Property: <span class="yellow">Width</span></h3>
<p class="box copy--small">Sets the width of an element.</p>
<p class="box copy--small">Value can be in pixels, percentage, or ems.</p>
<small class="blue">Does not include padding or borders, remember these add to the width.</small>
</section>
<!-- Height-->
<section>
<h3>Property: <span class="yellow">Height</span></h3>
<p class="copy--small box--small">Sets the height of an element.</p>
<p class="copy--small box--small">Value can be in pixels, percentage, or ems.</p>
<small class="blue">Does not include padding or borders, remember these add to the width and height.</small>
</section>
<!-- Exercise -->
<section>
<h3>Let's develop it!</h3>
<div class="">
<p class="box--small" style="text-decoration:underline;">Target each element with CSS:</p>
<ul class="copy--small list--tall">
<li>Make the <span class="blue">body</span> 900px wide.</li>
<li>Make the sidebar (<span class="blue"><aside></span>) 300px wide.</li>
<li>Make the content area (<span class="blue"><main></span>) 550px wide.</li>
<li>Make the <span class="blue">header</span> 150px tall</li>
</ul>
</div>
</section>
<section>
<h3>Check-in</h3>
<p class="copy--small box--small">Your styles should now contain rules like these:</p>
<pre><code class="css">
body {
width: 900px;
}
aside {
width: 300px;
}
main {
width: 550px;
}
header {
height: 150px;
}
</code></pre>
<small>Your sidebar isn't on the side yet, though! Don't worry, we'll get there. :)</small>
</section>
</section>
<!-- Break -->
<section>
<section>
<h1>Break time!</h1>
</section>
<!-- What's wrong with my code-->
<section>
<h3>Pop Quiz</h3>
<p class="copy--small box--small">Which one is invisible? Margin, padding or border?</p>
<img src="images/box-model-padding.png" width="650"/>
<small class="fragment"><span class="blue">Margin.</span> <br/>Neither margin or padding can have a color assigned, <br />but padding does "show" the background color of the content.</small>
</section>
<section>
<h3>Quiz Pop</h3>
<p class="copy--small box--small">What color will the paragraph text be?</p>
<pre><code class="css">
p {
color: red;
}
p {
color: blue;
}
</code></pre>
<small class="fragment">The paragraph text will be <span class="blue">blue</span>, because bottom rules override earlier rules.</small>
</section>
</section>
<section>
<section>
<h3>Which element should I use?</h3>
<a href="http://html5doctor.com/downloads/h5d-sectioning-flowchart.pdf" target="_blank"><img src="images/h5d-sectioning-flowchart.png" alt="HTML5 Doctor chart" width="800"/></a>
</section>
<!-- Divs -->
<section>
<h3>Element: <span class="yellow">Div</span></h3>
<p class="copy--small box--small">If no specific HTML5 structural element applies, then use a <code>div</code></p>
<ul class="copy--xsmall list--tall">
<li>A division, or section of content within an HTML page.</li>
<li>Used to group elements to format them with CSS.</li>
<li>Apply IDs & Classes to divs to give the browser more information about them.</li>
</ul>
<pre style="height: 100px; overflow: hidden"><code>
<div>
<p>Content<p>
<p>Content<p>
</div>
</code></pre>
<pre style="height: 100px; overflow: hidden"><code>
<div id="social">
<h1>Main Heading<h1>
</div>
</code></pre>
<pre style="height: 100px; overflow: hidden"><code>
<div class="sub-content">
<p>Some more content<p>
</div>
</code></pre>
</section>
<section>
<h3>Grouping elements with div</h3>
<ul class="box--small copy--small list--tall">
<li>The div tag is used everywhere to group elements together into sections.</li>
<li>For example, what if we want the first 2 paragraphs of a section to be right-aligned, purple & bold, but we don't want any other paragraphs to be right-aligned?</li>
<li>We would wrap them in a <code>div</code> element to style them differently.</li>
</ul>
</section>
<section>
<h3>Grouping elements with div</h3>
<pre style="height: 180px; overflow: hidden;"><code class="html">
<div class="align-right">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit</p>
<p>Sed do eiusmod tempor incididunt ut labore et dolore.</p>
</div>
<p>Magna aliqua. Ut enim ad minim veniam.</p>
<p>Quis nostrud exercitation ullamco.</a>
</code></pre>
<pre style="height: 140px; overflow: hidden;"><code class="css">
.align-right {
text-align: right;
color: purple;
font-weight: bold;
}
</code></pre>
<div style = "text-align:right; color: purple; font-weight: bold; font-size: 70%;">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit</p>
<p>Sed do eiusmod tempor incididunt ut labore et dolore.</p>
</div>
<div class="left-align" style="font-size: 70%;">
<p>Magna aliqua. Ut enim ad minim veniam.</p>
<p>Quis nostrud exercitation ullamco.</a>
</div>
</section>
<!-- Let's Develop It -->
<section>
<h3>Let's Develop It</h3>
<ul class="list--tall box--small copy--small ">
<li>Let's add a couple paragraphs to our <code>aside</code>, then group them using a <code>div</code>.</li>
<li>We'll style this <code>div</code> after we learn about IDs & classes!</li>
</ul>
<pre><code class="html">
<div>
<p>Your aside paragraph!</p>
<p>Your aside paragraph 2!</p>
</div>
</code></pre>
</section>
</section>
<section>
<!-- IDs vs Classes -->
<section>
<h2>Using IDs and Classes</h2>
<p class="copy--small box--small ">Often, targeting <strong>all of the HTML elements</strong> is not specific enough,<br/>you want to target items in certain areas of your layout.</p>
<ul class="copy--small list--tall">
<li>A uniquely-styled sidebar list</li>
<li>Styling footer links, rather than all links.</li>
<li>Different fonts in the aside</li>
</ul>
</section>
<!-- Selectors: ID-->
<section>
<h3>Selector: ID</h3>
<pre style="height: 80px; overflow: hidden"><code class="html">
#social {
property: value;
}
</code></pre>
<p class="copy--small box--small">Selects the element with an id of "social".</p>
<pre style="height: 170px; overflow: hidden"><code class="html">
<div id="social">
<img src="images/twitter.jpg" alt="twitter icon">
</div>
<div id="blog">
<img src="images/blog.jpg" alt="blog icon">
</div>
</code></pre>
<p><small>(The associated HTML.)</small></p>
<p class="green copy--xsmall fragment" style="margin-top:30px;">An ID should only be applied to a single element on the page.</p>
<p class="blue copy--xsmall fragment" style="margin-top:30px;">Using IDs in CSS is not recommended - try to use classes instead!</p>
</section>
<!-- Selectors: Class-->
<section>
<h3>Selector: Class</h3>
<pre style="height: 80px; overflow: hidden"><code class="html">
.warning {
color: red;
}
</code></pre>
<p class="copy--small box--small">Selects <em>all</em> elements with a class of "warning".</p>
<pre style="height: 60px; overflow: hidden"><code class="html">
<p class="warning">Run away!</p>
<p class="warning">Take cover!</p>
</code></pre>
<p><small>(The associated HTML.)</small></p>
<div class="copy--small box--small">
<p class="warning" style="color: red;">Run away!</p>
<p class="warning" style="color: red;">Take cover!</p>
</div>
</section>
<!-- ID vs Class example-->
<section>
<h3>IDs vs. Classes</h3>
<div class="box--small">
<p class=" copy--small"><span class="yellow">ID</span> -- Should only apply to <strong>one element</strong> on a webpage (like <code>#top</code> -- there is only one top of the page).</p>
<p><small>Can be used to link to different parts of a single page. (Example: <a href="http://www.npr.org/">npr.org</a>).</small></p>
<pre style="height: 40px; overflow: hidden; width: 42%; float: left;"><code class="html">
<p id="this_ID">
</code></pre>
<pre style="height: 40px; overflow: hidden; width: 42%; float: right;"><code class="css">
#this_ID { color: red; }
</code></pre>
</div>
<div style="clear:both; padding-top: 40px;">
<p class="copy--small"><span class="yellow">Class</span> -- Lots of elements can have the same class.</p>
<p><small>Ex. There can be many warnings on one webpage.</small></p>
</div>
<div>
<pre style="height: 80px; overflow: hidden; width: 42%; float: left;"><code class="html">
<p class="this_class">
<div class="this_class">
<a href="..." class="this_class">
</code></pre>
<pre style="height: 40px; overflow: hidden; width: 42%; float: right;"><code class="css">
.this_class { color: #333; }
</code></pre>
</div>
</section>
<!-- ID vs Class - analogy-->
<section>
<h3>IDs vs. Classes</h3>
<div class="left-align">
<p class="yellow box--small">Another way to think about it:</p>
<p class="copy--small">Like a department store, you just have one women's department, one men's department, one kids' department. These departments are like ID's.</p>
<p class="copy--small box--small">Inside each department are all kinds of products: sweaters, shirts, socks, in all colors and sizes. There are multiples of these, so these are like classes.</p>
</div>
</section>
<!-- Let's Develop It: Adding a class -->
<section>
<h3>Let's Develop It</h3>
<ul class="copy--small list--xtall box--small">
<li>Remember the <code>div</code> we created in <code>aside</code>? Let's give it a class of <code>align-right</code>.</li>
<li>Now we add a rule to <span class="green">styles.css</span> to define what <code>align-right</code> will do:
<pre style="height: 80px; overflow: hidden;"><code class="css">
.align-right {
text-align: right;
}
</code></pre>
</li>
<li>Feel free to create more classes on your own! You can even add multiple classes to an element, separated by spaces:
<pre style="height: 40px; overflow: hidden;"><code class="html">
<p class="align-right red warning">
</code></pre>
</li>
</ul>
</section>
</section>