-
Notifications
You must be signed in to change notification settings - Fork 0
/
class2.html
executable file
·944 lines (889 loc) · 38.6 KB
/
class2.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Girl Develop It - Intro to HTML + CSS, Class 2</title>
<meta name="description" content="Girl Develop It's Intro to HTML and CSS course, customized by Liz Shaw">
<meta name="author" content="Liz Shaw">
<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.css">
<link rel="stylesheet" href="css/theme/simple.css" id="theme">
<!-- For syntax highlighting -->
<!-- light editor<link rel="stylesheet" href="lib/css/light.css">-->
<!-- dark editor-->
<link rel="stylesheet" href="lib/css/dark.css">
<link rel="stylesheet" href="lib/css/zenburn.css">
<link rel="stylesheet" href="plugin/accessibility-helper/css/accessibility-helper.css">
<!-- If the query includes 'print-pdf', include the PDF print sheet -->
<script>
if (window.location.search.match(/print-pdf/gi)) {
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'css/print/pdf.css';
document.getElementsByTagName('head')[0].appendChild(link);
}
</script>
<!-- If use the PDF print sheet so students can print slides-->
<link rel="stylesheet" href="css/print/pdf.css" type="text/css" media="print">
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<div class="slides">
<!-- Code Your Own Website -->
<section>
<h2>HTML / CSS 4wk series</h2>
<img src="img/circle-gdi-logo.png" alt="GDI Logo" />
<h3>Intro to CSS</h3>
<p>
<small>Session 2</small>
</p>
</section>
<!-- Welcome-->
<section class="hide-pdf">
<h3>Welcome!</h3>
<div class = "left-align">
<p>Girl Develop It is here to provide affordable and accessible programs to learn software through mentorship and hands-on instruction.</p>
<p class ="green"><br />Some "rules":</p>
<ul>
<li>We are here for you!</li>
<li>Every question is important</li>
<li>Help each other</li>
<li>Have fun</li>
</ul>
<p> </p>
<p><strong>Thank you to our wonderful TAs!</strong></p>
<p>Course website: </p>
<p>Instructor contact info: </p>
</div>
</section>
<!-- Anatomy of a Website -->
<section>
<h3>Anatomy of a Website</h3>
<p>Your <span class="green">Content</span></p>
<p>+ <span class="green">HTML</span>: Structure</p>
<p>+ <span class="fragment grow highlight-blue">CSS</span>: Presentation</p>
<p>= <span class="fragment grow highlight-blue">Your Website</span></p>
<p>A website is a way to present your content to the world, using HTML to structure that content, and CSS to make it look good.</p>
<aside class="notes">Last week, focused on providing structure to our content with HTML. This week, adding CSS to make it look nice.</aside>
</section>
<!-- CSS: What Can It Do? -->
<section>
<h3>CSS: What can it do?</h3>
<p>All colored text, positioning, sizes</p>
<img src = "img/design-before-after.png">
<aside class="notes">Our class project</aside>
</section>
<!-- CSS: What is it? -->
<section>
<h3>CSS: What is it?</h3>
<ul>
<li>CSS stands for <span class="green">C</span>ascading <span class="green">S</span>tyle <span class="green">S</span>heets</li>
<li class="fragment">CSS describes how HTML elements are to be displayed when:
<ul>
<li class="fragment">on a <span class="blue">screen</span></li>
<li class="fragment">on <span class="blue">devices</span> (tablets, phones, etc.)</li>
<li class="fragment">on <span class="blue">printed paper</span></li>
</ul>
</li>
</ul>
<aside class="notes">In this class, only going to cover 'screen' aspect. During Intermediate HTML/CSS, get into responsive development, which is when your page responds to the width of your device.</aside>
</section>
<section>
<h3>CSS: What is it?</h3>
<P> </P>
<p><a href="http://girldevelopit.com" target="_blank">An example »</a></p>
<aside class="notes">Break this site's CSS in the Inspector to show what its power is. Responsive development (via media queries) in intermediate class. Pull up a page and remove the CSS in the Inspector as an example! Indicate how they've all seen pages load without CSS.</aside>
</section>
<!-- CSS: What does it look like? -->
<section>
<h3>CSS in Action</h3>
<img src="img/css.png">
</section>
<!-- HTML + CSS -->
<section>
<h3>HTML + CSS</h3>
<ul>
<li><span class="blue">HTML</span> structures the content:
<pre class="html">
<code><p>This paragraph should have red text.</p></code>
</pre>
</li>
<li class="fragment">Since <span class="blue">CSS</span> is a different language, it is kept in a different file (<span class="green">.css</span> instead of <span class="green">.html</span>). CSS says how your structured content should look:<br />
<pre>
<code class="css">
p {
color: red;
}
</code>
</pre></li>
<li class="fragment">On your <span class="blue">Website</span>, the result is:
<p style="color:red;">This paragraph should have red text.</p></li>
</ul>
<p><small class="fragment green"><br />Without CSS, your HTML pages would look boring ☺</small></p>
<aside class="notes">We'll go over CSS syntax shortly.</aside>
</section>
<!-- How does it work? -->
<section>
<h3>How does it work?</h3>
<ol>
<li>You make an HTML file</li>
<li class="fragment">You make a CSS file that <span class="blue">describes</span> how specific HTML elements should look</li>
<li class="fragment">Within the <em><head></head></em> of your HTML file, you <span class="blue">link</span> to your CSS file</li>
<li class="fragment">The CSS <span class="blue">searches through and selects</span> specific elements that you've said should be styled, and applies that styling</li>
</ol>
</section>
<!-- CSS Syntax -->
<section>
<h3>CSS Syntax</h3>
<img src="img/css-syntax.png" alt="CSS Syntax" style="border: none; box-shadow: none;max-height:250px;"/>
<pre>
<code class = "css">selector {
property: values;
}</code></pre>
<p> </p>
<ul>
<li>A block of CSS code is a <span class="blue">rule</span></li>
<li class="fragment">The rule starts with a <span class="blue">selector</span></li>
<li class="fragment">It has sets of <span class="blue">properties</span> and <span class="blue">values</span></li>
</ul>
<aside class="notes">Don't really need to know what each portion is called, more concerned with you knowing how to use them. Selector, curly brace, property, colon, property value, semicolon. Whitespace doesn't matter.</aside>
</section>
<section>
<h3>CSS Syntax</h3>
<img src="img/css-syntax.png" alt="CSS Syntax" style="border: none; box-shadow: none;max-height:300px;"/>
<p>You can add multiple property-value pairs to a rule, each ending with a semicolon:</p>
<pre>
<code class = "css">body {
color: lightblue;
background-color: black;
text-transform: uppercase;
}</code></pre>
</section>
<!-- CSS Coding Tip #1 -->
<section>
<h3>CSS Coding Tip #1</h3>
<p>Just like HTML, CSS ignores whitespace. All you need is for each rule to be in the correct format.</p>
<p> </p>
<div>
<div style="float:left;width:33.33%;">
<p class="green"><u>Best: ✔</u></p>
<pre><code class="css" style="font-size:90%;">
p {
font-size: 22px;
text-align: center;
color: red;
}
</code></pre>
</div>
<div style="float:left;width:33.33%">
<p class="orange"><u>Decent:</u></p>
<pre><code class="css" style="font-size:90%;">
p{font-size:22px;text-align:center;color:red;}
</code></pre>
</div>
<div style="float:left;width:33.33%;">
<p class="orange"><u>Not-so-great:</u></p>
<pre><code class="css" style="font-size:90%;">
p {
font-size:22px;
text-align : center;
color: red;
}
</code></pre>
</div>
<p> </p>
<p><br />The base format of a rule is <span class="green">selector{property:value;}</span><br /><small>It doesn't matter where whitespace goes, as long as the format is correct</small></p>
</div>
</section>
<!-- Connecting CSS to HTML -->
<section>
<h3>Connecting CSS to HTML</h3>
<p class="blue">3 ways</p>
<ol class="left-align">
<li>Inline</li>
<li>Embedded</li>
<li class="green">External ✔</li>
</ol>
<aside class="notes">Why mention if they aren't recommended? Just in case students see it as they are editing code.</aside>
</section>
<section>
<h3>Connecting CSS to HTML</h3>
<p class="blue">1. Inline</p>
<pre><code class="html"><p style="color:red;font-size:12px;">Some text.</p></code></pre>
<ul style="margin-top:1em;">
<li style="color:red;">Not preferred <span style="font-size:110%;">✗</span></li>
<li>Uses the HTML attribute called <em>style</em></li>
<li>Difficult to use in large projects</li>
</ul>
<aside class="notes">Mention that we are in the HTML file now, NOT the CSS file.</aside>
</section>
<section>
<h3>Connecting CSS to HTML</h3>
<p class="blue">2. Embedded</p>
<pre><code class="html"><head>
<style type="text/css">
p {
color: red;
font-size: 12px;
}
</style>
</head></code></pre>
<ul style="margin-top:1em;">
<li style="color:red;">Not preferred <span style="font-size:110%;">✗</span></li>
<li>Inside <em>head</em> element</li>
<li>Uses <em>style</em> tag</li>
<li>Needs to be placed in each HTML file</li>
</ul>
<aside class="notes">Mention that we are in the HTML file now, NOT the CSS file.</aside>
</section>
<section>
<h3>Connecting CSS to HTML</h3>
<p class="blue">3. External</p>
<pre><code class = "html"><head>
<link rel="stylesheet" href="css/styles.css" />
</head></code></pre>
<ul style="margin-top:1em;">
<li class="green">Preferred by developers everywhere! ✔</p>
<li class="fragment">External CSS saves a lot of work by controlling the look and feel of multiple pages at once</li>
<li class="fragment">Easy to maintain</li>
<li class="fragment">Useful when working with a team</li>
<li class="fragment">Reduced bandwidth</li>
<li class="fragment">Easier for search engines to crawl your site's content</li>
</ul>
<aside class="notes">Team: For content entry, inefficient to keep flipping through a style guide to see what color, font-size, etc. a certain heading should be. Instead, you can let the CSS control the styling for you. Also introduce concept of 'separation of concerns'. Divide and conquer! Bandwidth: caching, so downloaded once.</aside>
</section>
<section>
<h3>Connecting CSS to HTML</h3>
<p class="blue">3. External</p>
<p><img src="img/external-stylesheet.png" /></p>
</section>
<!-- Let's Develop It! -->
<section class="hide-pdf">
<h3>Let's Develop It!</h3>
<p><img src="img/folderstructure1.png" /></p>
<ol>
<li>Make a copy of your <span class="orange">class1</span> folder and call it <span class="orange">class2</span></li>
<li>Create a new CSS file and save it as <span class="orange">styles.css</span> within the <span class="orange">class2/css</span> folder</li>
<li>Add a link to <span class="orange">css/styles.css</span> in class2's <span class="orange">index.html</span> file</li>
</ol>
<p class="green fragment"><br />Now we can begin styling!</p>
<aside class="notes">Do this with students! Point out that the relative path is the same, since we're in index.html and going into the images folder.</aside>
</section>
<!-- 1. Styling: The Element Selector, Text Color, & Backgrounds -->
<section>
<h3>Selector: Element</h3>
<p>Enter the element's <span class="orange">tag name</span> to target those elements:</p>
<pre><code class = "css">
p {
color: aqua;
}
</code></pre>
<p class="blue"><br /><small><em>p { }</em> in CSS corresponds to <p></p> in HTML</small></p>
<div class="fragment">
<p>The following selects all image elements:</p>
<pre class=""><code class = "css">
img {
width: 600px;
}
</code></pre>
<p class="blue"><br /><small><em>img { }</em> in CSS corresponds to <img /> in HTML</small></p>
</div>
<aside class="notes">There are other selectors that we'll get into later. Start with this one so we can style different elements as we move along. CODE THE P AND IMG EXAMPLES FOR THEM.</aside>
</section>
<section>
<h3>Property: <em>color</em></h3>
<p>The <span class="orange">color</span> property changes the color of the text.</p>
<pre><code class = "css">
p {
color: red;
color: #ff0000;
color: rgb(255, 0, 0);
color: rgba(255, 0, 0, 0.7);
}
</code></pre>
<p class="left-align blue" style="margin-left:1em;margin-top:20px">Options:</p>
<ul style="display:block;margin-left:2em;font-size:80%;">
<li>Color name (e.g. <em>white</em>)</li>
<li>Hexadecimal value (e.g. <em>#FFFFFF</em> or <em>#FFF</em>)</li>
<li>RGB value (e.g. <em>rgb(255, 255, 255)</em> )</li>
<li>RGBA value for opacity (e.g. <em>rgba(255, 255, 255, 0.5)</em> )</li>
</ul>
<p style="margin-top:20px;">There are 140 reserved color names, including: <font color="black">black</font>, <font color="blue">blue</font>, <font color="aqua">aqua</font>, <font color="fuchsia">fuchsia</font>, <font color="grey">grey</font>, <font color="green">green</font>, <font color="lime">lime</font>, <font color="maroon">maroon</font>, <font color="navy">navy</font>, <font color="olive">olive</font>, <font color="purple">purple</font>, <font color="red">red</font>, and <font color="teal">teal</font><br /><a href="http://www.w3schools.com/cssref/css_colornames.asp" target="_blank">See a full list »</a></p>
<!-- Note to self: Make a pull request for this slide, as it is out-of-date in the main repo -->
<aside class="notes">NOT EXPECTED TO KNOW HOW THIS WORKS: Lots of ways to refer to colors other than the color name. Mention that, when you see the same property on different lines, that just means they're different settings you can use for that property.<br />Mention that the RGBA controls opacity, while RGB is solid.</aside>
</section>
<section>
<h3>Property: <em>background-color</em></h3>
<p>The <span class="orange">background-color</span> property changes the color of the background</p>
<pre><code class = "css">
body {
background-color: black;
background-color: #000000;
background-color: rgb(0, 0, 0);
background-color: rgba(0, 0, 0, 0.7);
}
</code></pre>
<aside class="notes">Mention RGBA if you haven't already. Do this alongside students!</aside>
</section>
<section>
<h3>Selector: Descendant</h3>
<p>To target elements that are descended from another element, use a <span class="blue">selector for the ancestor</span>, then <span class="blue">a space</span>, then a <span class="blue">selector for the descendant</span>:</p>
<div>
<div class="left" style = "width:55%">
<p><span class="orange"><u>HTML:</u></span></p>
<pre class="apache"><code><div>
Buy one get one
<strong>free</strong>
<p>
Offer valid
<strong>today</strong>
only
</p>
</div></code></pre>
</div>
<p><span class="orange"><u>CSS:</u></span></p>
<div>
<pre><code class="css">
div strong {
background-color: yellow;
color: blue;
}
</code></pre>
</div>
<div class ="clear"></div>
</div>
<div class="fragment">
<p> </p>
<p><span class="orange"><u>Result:</u></span></p>
<div>
Buy one get one <strong style="background:yellow;color:blue;text-transform: uppercase;">free</strong>
<p>Offer valid <strong style="background:yellow;color:blue;">today</strong> only</p>
</div>
</div>
<aside class="notes">Ask students which words would have a yellow BG with blue italicised text. Ask students what element would be an immediate child of the div. CODE EXAMPLE WITH STRUCTURE, AND ASK WHAT ANCESTORS OF A CERTAIN ELEMENTS WOULD HAVE. Also ask about two different ways to target an H1, for example.</aside>
</section>
<!-- Let's Develop It! -->
<section>
<h3>Let's Develop It!</h3>
<p class="blue">Let's get stylin'</p>
<ol style="margin-top:1em;">
<li>Apply a background color to your <span class="orange">body</span> element and/or other elements</li>
<li>Apply text colors to elements (e.g. <span class="orange">paragraph</span>, <span class="orange">heading</span>, and <span class="orange">list</span> elements)</li>
<li>Try to use the <span class="orange">decendant selector</span> to style descendants</li>
</ol>
</section>
<!-- 2. Styling: Fonts -->
<section>
<h3>Property: <em>font-family</em></h3>
<p>The <span class="orange">font-family</span> property defines which font is used</p>
<pre><code class = "css">
body {
font-family: Helvetica;
font-family: "Helvetica Neue";
font-family: Arial;
font-family: sans-serif;
}
</code></pre>
<p class="blue"><small><br />If a font name is more than one word, it goes in quotation marks (like "Helvetica Neue").</small></p>
<div class="fragment" style="font-size:90%;">
<p><span class="green">Preferred ✔</span>: Use a prioritized list. The page will load whichever font it recognizes first in the list:</p>
<pre><code class = "css">
body {
font-family: Helvetica, "Helvetica Neue", Arial, sans-serif;
}
</code></pre>
<p class="fragment blue"><br />Helpful site: <a href="http://cssfontstack.com" target="_blank">CSSFontStack.com »</a></p>
</div>
<aside class="notes">Recognizes = have downloaded to their machine. Mention web-safe fonts, and also give example with an uncommon font (e.g. Segoe UI). Also, say that these two blocks of CSS mean different things. The first overwrites, while the second is a prioritization. Called 'family' because all of these fonts look similar. Point out that applying fonts, background, etc. to the body element applies it to all the children.</aside>
</section>
<section>
<h3>Property: <em>font-size</em></h3>
<p>The <span class="orange">font-size</span> property specifies the size of the font.</p>
<pre><code class = "html">
p {
font-size: 16px;
font-size: 1em;
font-size: 100%;
}
</code></pre>
<p class="left-align blue" style="margin-left:1em;margin-top:20px">Options include:</p>
<ul style="display:block;margin-left:2em;font-size:80%;">
<li>Pixels</li>
<li>"em" Units</li>
<li>Percentages</li>
</ul>
<p> </p>
<p class="fragment">The default <em><body></body></em> size is 16px<br /> Usually <strong>16px = 1em = 100%</strong></p>
<aside class="notes">Mention default styling. There's a reason why, last week, our links were rendered as blue, the headings larger, and 'strong' elements as bold, etc. All of that can be overridden with CSS, which is what we're going to do in this class.</aside>
</section>
<section>
<h3>Property: <em>font-size</em></h3>
<p class="blue"><em>px</em> versus <em>em</em> versus <em>%</em></p>
<p><small>Pixels are a fixed-size unit — they don't change relative to their ancestor's font size. Percentages and "em"s are scalable and relative to their ancestor's font size.</small></p>
<img src="img/nesting-font-sizes.png" alt="Relative versus scalable font sizes" />
<aside class="notes">Stress that you don't need to worry too much about specifics right now -- while learning, use pixels. This concept will come up in intermediate class so it's good to be aware of. CODE AN EXAMPLE of the difference between pixel and em/percentage. Use half and double. Note: Pixels and em/percentage are not just for font sizes -- you can use them for elements that have widths, heights, etc. Recommend ems and percentages (or other scalable units) over pixels.
<pre><code class="html">
<p>The default body font size (16px)</p>
<main>
<p>Container's default font size</p>
<p class="font-size-40px">Font size of 40px</p>
<p id="font-size-double-em">Font size of 2em<p>
<p id="font-size-half-em">Font size of .5em</p>
<p id="font-size-double-percent">Font size of 200%</p>
<p id="font-size-half-percent">Font size of 50%</p>
</main>
</pre></code>
</aside>
</section>
<section>
<h3>Properties:<br /><em>font-style</em> and <em>font-weight</em></h3>
<p>The <span class="orange">font-style</span> property sets italic styling for text<br />The <span class="orange">font-weight</span> property sets text boldness</p>
<pre><code class = "css">
h4 {
font-style: normal;
font-style: italic;
font-style: oblique;
font-weight: normal;
font-weight: bold;
}
</code></pre>
</section>
<section>
<h3>Property: <em>font-variant</em></h3>
<p>Use <span class="orange">font-variant</span> to make <em>small-caps</em> text</p>
<pre><code class = "css">
h1 {
font-variant: normal;
font-variant: small-caps;
}
</code></pre>
<p class="green" style="font-variant:small-caps;">An Example of 'small-caps' Text</p>
<aside class="notes">All capitalized letters from HTML are made taller</aside>
</section>
<section>
<h3>Property: <em>line-height</em></h3>
<p>The <span class="orange">line-height</span> property specifies text line height</p>
<pre><code class = "css">
p {
font-size: 10px;
line-height: 20px;
line-height: 2em;
line-height: 2;
}
</code></pre>
<p><img src="img/word-line-spacing.jpg" /></p>
<aside class="notes">Mention how these are all doing the same thing, as multiples of two. Multiple of whatever that element's font size is, like previous example.</aside>
</section>
<section>
<h3>Property: <em>text-transform</em></h3>
<p>Use <span class="orange">text-transform</span> to make text lowercase, capitalized, or uppercase</p>
<pre><code class = "css">
h1 {
text-transform: lowercase;
text-transform: capitalize;
text-transform: uppercase;
}
</code></pre>
<p> </p>
<p class="green" style="text-transform:lowercase;">an Example of 'lowercase' Text</p>
<p class="green" style="text-transform:capitalize;">an Example of 'capitalize' Text</p>
<p class="green" style="text-transform:uppercase;">an Example of 'uppercase' Text</p>
<aside class="notes">Mention how, in the HTML, the text is all lowercase. Possibly code this out.</aside>
</section>
<section>
<h3>Property: <em>text-align</em></h3>
<p>The <span class="orange">text-align</span> property aligns text to the left, right, or center</p>
<pre><code class = "css">
p {
text-align: left;
text-align: right;
text-align: center;
}
</code></pre>
</section>
<!-- Let's Develop It! -->
<section>
<h3>Let's Develop It!</h3>
<p class="blue">Let's style some text elements with:</p>
<ol style="margin-top:1em;">
<li>Font family</li>
<li>Font sizes</li>
<li>Font boldness and italicization</li>
<li>Text capitalization</li>
<li>Line heights</li>
<li>Text alignment</li>
</ol>
<aside class="notes">A whole lot! Don't need to use all. Mention that you can append this styling to the same rule, and code an example.</aside>
</section>
<!-- More Selectors -->
<section>
<h2>More selectors, you say?</h2>
<aside class="notes">Rare that you'll want every div to have a black background, for instance, or every link to be the same color. Need a way to narrow that down further.</aside>
</section>
<section>
<h3>Selector: Class</h3>
<p>Enter <span class="blue">a period (.)</span><br />followed directly by the <span class="blue">class attribute's value</span><br />to target all elements with that class:</p>
<div>
<div class="left" style = "width:60%">
<p><span class="orange"><u>HTML:</u></span></p>
<pre class="apache"><code>
<p class="warning">Lorem ipsum</p>
<span class="warning">Dolor sit amet</p>
</code></pre>
</div>
<p><span class="orange"><u>CSS:</u></span></p>
<div>
<pre><code class="css">
.warning {
color: red;
}
</code></pre>
</div>
<div class ="clear"></div>
</div>
<div class="fragment">
<p> </p>
<p><span class="orange"><u>Result:</u></span></p>
<p style="color:red;">Lorem ipsum</p>
<span style="color:red;">Dolor sit amet</span>
<p class="blue fragment"><br /><small><em>.red { }</em> in CSS corresponds to <tagname class="red"></tagname> in HTML</small></p>
</div>
</section>
<section>
<h3>Selector: Class</h3>
<p class="blue">Using Multiple Classes</p>
<p>Assign multiple classes to an element by separating each class with <span class="orange">a space</span> <u>in the HTML</u>:</p>
<div>
<div class="left" style="width:60%">
<p><span class="orange"><u>HTML:</u></span></p>
<pre class="apache"><code><p class="green bordered">Cowabunga!</p>
<p class="green">said Michaelangelo</p></code></pre>
</div>
<p><span class="orange"><u>CSS:</u></span></p>
<div>
<pre><code class="css">
.green {
color: green;
}
.bordered {
border-width: 3px;
border-style: dashed;
border-color: fuchsia;
}
</code></pre>
</div>
<div class ="clear"></div>
</div>
<div class="fragment">
<p><span class="orange"><u>Result:</u></span></p>
<p style="color:green;border-width:3px;border-style:dashed;border-color:fuchsia;">Cowabunga!</p>
<p style="color:green;">said Michaelangelo</p>
</div>
<p class="blue fragment"><small>Since the first <em><p></p></em> element is targeted by both the <em>.green</em> and <em>.bordered</em> CSS rules, it is both green and bordered.</small></p>
<aside class="notes">Code an example of this, where you add 'bordered' to several different elements</aside>
</section>
<section>
<h3>Selector: ID</h3>
<p>To target elements with a specific ID, use the <span class="blue">hashtag (#)</span>, followed by the <span class="blue">ID attribute's value</span>:</p>
<div>
<div class="left" style = "width:60%">
<p><span class="orange"><u>HTML:</u></span></p>
<pre class="apache"><code>
<div id="featured">
<a href="result1.html">
The One Featured Search Result's Title
</a>
<p>
A description of this search result
</p>
</div>
</code></pre>
</div>
<p><span class="orange"><u>CSS:</u></span></p>
<div>
<pre><code class="css">
#featured {
background-color: #F5E17F;
}
</code></pre>
</div>
<div class ="clear"></div>
</div>
<div class="fragment">
<p> </p>
<p><span class="orange"><u>Result:</u></span></p>
<div style="background:#F5E17F;text-align:left;">
<a href="#" style="color:blue;">The One Featured Search Result's Title</a>
<p>A description of this search result</p>
</div>
</div>
<aside class="notes">Mention hexadecimal codes for colors, if you haven't already</aside>
</section>
<section>
<h3>Selector: ID</h3>
<p>You can assign multiple classes to an element, but ...</p>
<p class="fragment">ID should only apply to <span class="blue">one element</span> on the page</p>
<p> </p>
<p class="fragment">Why? <span class="orange">IDs are unique</span></p>
<aside class="notes">Think of ID like an element's SSN. HTML and CSS don't throw errors like Javascript -- good to get in the habit now.</aside>
</section>
<section>
<h3>IDs vs. Classes</h3>
<p class="blue">A Practical Example</p>
<aside class="notes">Ask students to raise their hands if they have dark hair. In that way, there is a class of people with a similar style, but each person has their own ID/identity. Also, code a search results example!</aside>
</section>
<section>
<h3>Selector: Descendant</h3>
<p class="blue">Using Classes or IDs</p>
<p>The descendant and ancestor selectors don't have to be tag names; they can be classes, IDs, etc.</p>
<div>
<div class="left" style = "width:60%;font-size:90%">
<p><span class="orange"><u>HTML:</u></span></p>
<pre class="apache"><code>
<ul id="intro">
<li>
We are an
<span class="fancy-text">amazing</span>
team of developers
</li>
<li>
Located in
<span class="fancy-text">beautiful</span>
Cambridge, MA
</li>
</ul></code></pre>
</div>
<p><span class="orange"><u>CSS:</u></span></p>
<div>
<pre><code class="css">
#intro .fancy-text {
background-color: yellow;
color: blue;
font-style: italic;
}
</code></pre>
</div>
<div class ="clear"></div>
</div>
<div class="fragment">
<p> </p>
<p><span class="orange"><u>Result:</u></span></p>
<div>
<ul>
<li>We are an <span style="background:yellow;color:blue;font-style:italic;">amazing</span> team of developers</li>
<li>Located in <span style="background:yellow;color:blue;font-style:italic;">beautiful</span> Cambridge, MA</li>
</ul>
</div>
</div>
<aside class="notes">As long as your CSS has a space in between each selector, it will target the descendant (after the space).</aside>
</section>
<section>
<h3>Selector: Elements with a Specific Class</h3>
<p>To select an element with a specific class and tag name, use the <span class="blue">tag name</span>, followed by <span class="blue">a period (.)</span>, then the <span class="blue">class attribute's value</span>:</p>
<div>
<div class="left" style = "width:60%">
<p><span class="orange"><u>HTML:</u></span></p>
<pre class="apache"><code>
<p class="red">Lorem ipsum</p>
<span class="red">Dolor sit amet</span>
</code></pre>
</div>
<p><span class="orange"><u>CSS:</u></span></p>
<div>
<pre><code class="css">
span.red {
color: red;
}
</code></pre>
</div>
<div class ="clear"></div>
</div>
<div class="fragment">
<p> </p>
<p><span class="orange"><u>Result:</u></span></p>
<p>Lorem ipsum</p>
<span style="color:red;">Dolor sit amet</span>
</div>
<p class="orange fragment"><br /><small>Make sure there are no spaces in between your tag name, period, and class!</small></p>
</section>
<section>
<h3>Selector Order and Spacing</h3>
<p class="blue">Why are these three rules so different?</p>
<div>
<pre>
<code class="css">
.class div {
color: red;
}
div .class {
color: green;
}
div.class {
color: orange;
}
</code>
</pre>
</div>
<p><a href="http://codepen.io/anon/pen/zvdWgL?editors=110" target="_blank">Let's take a look »</a></p>
<aside class="notes">
<pre><code>
<div>
<span class="class">
1
</span>
<div class="class">
2
<div>
3
</div>
</div>
</div>
</code></pre>Rule of thumb: If there's a space -- in CSS -- then the portion after the space is a descendent. If there is no space, you are combining selectors. The first part is "select any element with this class name" and the second part is "select any div". Put them together with a space and you get "select any div that is a descendant of any element with this class name".</aside>
</section>
<section>
<h3>Cascading</h3>
<p class="blue"><small>What does the <span class="orange">cascading</span> in <span class="orange">C</span>ascading <span class="orange">S</span>tyle <span class="orange">S</span>heets mean?</small></p>
<p>Styles "cascade" down until changed</p>
<div>
<div class="left" style = "width:60%;">
<p><span class="orange"><u>HTML:</u></span></p>
<pre class="apache"><code>
<p>Paragraph 1</p>
<p class="red">Paragraph 2</p>
<p class="red" id="special">Paragraph 3</p>
</code></pre>
</div>
<p><span class="orange"><u>CSS:</u></span></p>
<div>
<pre><code class="css">
p{
color: blue;
font-family: Impact;
}
.red{
color: red;
}
#special{
font-family: Arial;
}
</code></pre>
</div>
<div class ="clear"></div>
</div>
<div class="fragment">
<p> </p>
<p><span class="orange"><u>Result:</u></span></p>
<p style="color:blue;font-family:Impact,Haettenschweiler,'Franklin Gothic Bold',Charcoal,'Helvetica Inserat','Bitstream Vera Sans Bold','Arial Black',sans serif;">Paragraph 1</p>
<p style="color:red;font-family:Impact,Haettenschweiler,'Franklin Gothic Bold',Charcoal,'Helvetica Inserat','Bitstream Vera Sans Bold','Arial Black',sans serif;">Paragraph 2</p>
<p style="color:red;font-family:Arial;">Paragraph 3</p>
</div>
<aside class="notes">Make an example with your existing code, and show how styles come through in inspector</aside>
</section>
<!-- Let's Develop It! -->
<section>
<h3>Let's Develop It!</h3>
<p> </p>
<ol>
<li>In your HTML, add classes and IDs to elements</li>
<li>In your CSS, use selectors to style the following:<p> </p>
<ul>
<li>Elements with the same class</li>
<li>An element with an ID</li>
<li>Elements with a specific tag and class</li>
<li>Descendants of an element</li>
<li>Descendants of a class or ID</li>
</ul>
</ol>
<aside class="notes">Do an example with 'red' or something basic.</aside>
</section>
<!-- Next Week -->
<section class="hide-pdf">
<h2>Next Week</h2>
<p class="blue">Coding Page Layouts — Beyond The Basics</p>
<p>We'll also start working on our project!</p>
<p> </p>
<p><small>If you haven't already, try to use each of the properties and selectors discussed in the lecture today and save your HTML and CSS files.</small></p>
</section>
<section>
<h2>Homework</h2>
<ul>
<li>Make another file
<li>Link your pre-existing css file (src)
<li>Link these two files together with html a href
</ul>
</section>
<section class="hide-pdf">
<h3>Questions?</h3>
<div style="font-size:1200%; height:100%; margin-top:20%" class="blue">?
<div class="clear"></div>
</div>
<aside class="notes">Can always email me!</aside>
</section>
</div>
<footer>
<div class="copyright">
HTML & CSS 4wk Series <span class="red">♥</span> Boulder/Denver |
<a rel="license" href="http://creativecommons.org/licenses/by-nc/3.0/deed.en_US"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc/3.0/80x15.png" />
</a>
</div>
</footer>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.min.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
transition: 'slide', // none/fade/slide/convex/concave/zoom
// Optional reveal.js plugins
dependencies: [{
src: 'lib/js/classList.js',
condition: function() {
return !document.body.classList;
}
}, {
src: 'plugin/markdown/marked.js',
condition: function() {
return !!document.querySelector('[data-markdown]');
}
}, {
src: 'plugin/markdown/markdown.js',
condition: function() {
return !!document.querySelector('[data-markdown]');
}
}, {
src: 'plugin/highlight/highlight.js',
async: true,
condition: function() {
return !!document.querySelector('pre code');
},
callback: function() {
hljs.initHighlightingOnLoad();
}
}, {
src: 'plugin/zoom-js/zoom.js',
async: true
}, {
src: 'plugin/notes/notes.js',
async: true
}, {
src: 'plugin/accessibility-helper/js/accessibility-helper.js',
async: true,
condition: function() {
return !!document.body.classList;
}
}]
});
</script>
</body>
</html>