-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsemantics.html
344 lines (306 loc) · 9.82 KB
/
semantics.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css"
integrity="sha512-EZLkOqwILORob+p0BXZc+Vm3RgJBOe1Iq/0fiI7r/wJgzOFZMlsqTa29UEl6v6U6gsV4uIpsNZoV32YZqrCRCQ=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/themes/prism-okaidia.min.css"
integrity="sha512-mIs9kKbaw6JZFfSuo+MovjU+Ntggfoj8RwAmJbVXQ5mkAX5LlgETQEweFPI18humSPHymTb5iikEOKWF7I8ncQ=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/prism.min.js"
integrity="sha512-YBk7HhgDZvBxmtOfUdvX0z8IH2d10Hp3aEygaMNhtF8fSOvBZ16D/1bXZTJV6ndk/L/DlXxYStP8jrF77v2MIg=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<title>Brief Intro to Semantic HTML</title>
<style>
:root {
--prime: #F92672;
--delta: #0CFAA5;
--back: #010D09;
--highlighted: white;
--hback: #067A52;
--preback: #3B091B;
background: var(--back);
}
/* -- SLIDESHOW LIB -- */
.slide {
display: flex;
font-size: 20px;
flex-direction: column;
justify-content: center;
align-items: center;
}
@media screen and (min-width: 60em) {
html,
body {
scrollbar-width: none;
font-size: 16px;
padding: 0;
margin: 0;
}
.slide {
height: 100vh;
}
}
/* -- /SLIDESHOW LIB -- */
/* Composition */
article {
color: var(--delta);
width: 65%;
margin: 0 auto;
}
dl {
max-width: 100%;
}
/* Utility */
h1 {
text-align: center;
}
mark {
color: var(--highlighted);
background-color: var(--hback);
}
pre,
code {
max-width: 100%;
overflow-x: auto;
background: var(--preback);
}
strong code {
font-weight: bolder;
}
@media screen and (min-width: 60em) {
.flex {
display: flex;
width: 100%;
justify-content: space-between;
align-items: flex-start;
}
}
.sample {
background: var(--preback);
border-radius: 0.5em;
border: 1px solid white;
padding: 0.5em;
}
/* Block */
blockquote {
border-radius: 0.5em;
border-left: 3px solid var(--hback);
padding-left: 1.2em;
font-style: italic;
}
.spectrum {
width: 100%;
display: flex;
justify-content: space-between;
border-radius: 0.5em;
padding: 0.5em 0.5em 1em;
background: linear-gradient(90deg, var(--prime), var(--delta));
position: relative;
}
.spectrum::after {
content: '';
position: absolute;
bottom: 0.3em;
left: 0.75em;
right: 0.75em;
border-radius: 0.5em;
height: 0.3em;
background: linear-gradient(90deg, black, white);
}
/* -- PRISM HAX -- */
pre.language-html {
background: var(--hback);
padding: 0.5em;
}
code.language-html {
background: var(--back);
}
.token.tag {
color: var(--prime);
}
.token.attr-name {
color: var(--delta);
}
/* -- /PRISM HAX -- */
</style>
</head>
<body>
<article>
<section class="slide" id="title">
<h1>A Brief Intro to Semantic HTML</h1>
</section>
<section class="slide" id="tldw">
<h2>Anti-clickbait</h2>
<ul>
<li>Using semantic HTML is good for accessibility, SEO and dev.</li>
<li>Some obvious ongoing costs that decrease with familiarity.</li>
<li>Less obvious benefits that increase with familiarity.</li>
<li>
<a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element">
https://developer.mozilla.org/en-US/docs/Web/HTML/Element
</a>
</li>
</ul>
</section>
<section class="slide" id="what">
<h2>What is <em>Semantic HTML?</em></h2>
<blockquote>
Semantic HTML is the use of HTML markup to <mark>reinforce the semantics, or meaning, of the information</mark>
in webpages and web applications <mark>rather than merely to define its presentation or look</mark>.
- <a href="https://en.wikipedia.org/wiki/Semantic_HTML">Wikipedia</a>
</blockquote>
(Highlights mine.)
</section>
<section class="slide" id="example" language-html>
<!-- Apologies in advance; there's no nice way of embedding HTML in HTML -->
<!-- (Don't suggest CDATA, it doesn't play nice with the Prims syntax highlighter. Alas.) -->
<pre><code class="language-html"><div class="slide" id="what">
<div class="title">What is <span class="italic">Semantic HTML?</span></div>
<div class="quote">
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
<span class="highlight">sed do eiusmod tempor
incididunt</span> ut labore et dolore magna aliqua.
</div>
(Highlights mine.)
</div></code></pre>
<pre><code class="language-html"><section class="slide" id="what">
<h2>What is <em>Semantic HTML?</em></h2>
<blockquote>
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
<mark>sed do eiusmod tempor incididunt</mark> ut
labore et dolore magna aliqua.
</blockquote>
(Highlights mine.)
</section></code></pre>
</section>
<section class="slide" id="why">
<h2>Why do we care?</h2>
<ul>
<li>Accessibility</li>
<li>SEO</li>
<li>Ease of development</li>
</ul>
</section>
<section class="slide" id="freebies">
<h2>Good news!</h2>
<p>Headings <code>h1</code>-<code>h6</code> are one of the most important pieces of semantic information in a
page.</p>
<p>(Hopefully you're already using them.)</p>
</section>
<section class="slide" id="beyond">
<h2>Going beyond headings</h2>
<ul>
<li><em>"Can I be more precise?"</em></li>
<li>Spectrum of semantics:
<ul>
<li class="spectrum">
<code>div</code>
<code>section</code>
<code>form</code>
</li>
<li class="spectrum">
<code>span</code>
<code>code</code>
<code>button</code>
</li>
</li>
</ul>
<li>Starting points:
<ul>
<li>Page regions: <code>main</code>, <code>nav</code>, <code>header</code>/<code>footer</code></li>
<li>Content structure:
<code>article</code>,
<strong><code>section</code></strong>,
<code>aside</code>,
<code>p</code>
</li>
<li>Text: <code>em</code>, <code>strong</code>, <code>code</code>, <code>mark</code></li>
<!-- Oh boy is it confusing to keep writing "<code>tag</code>" rather than "<tag>"" -->
</ul>
</li>
</ul>
</section>
<section class="slide" id="bonus">
<dl>
<dt>Details/summary</dt>
<dd class="flex">
<pre><code class="language-html"><details>
<summary>
Expand Deet
</summary>
Hello there.
</details></code></pre>
<details class="sample">
<summary>
Expand Deet
</summary>
Hello there.
</details>
</dd>
<dt>Definition lists</dt>
<dd>
<pre><code class="language-html"><dl>
<dt>MDN Glossary - Semantics</dt>
<dd><a href="...">...</a></dd></dt>
<dt>MDN HTML Elements</dt>
<dd><a href="...">...</a></dd>
</dl></code></pre>
</dl>
</section>
<section class="slide" id="conclusion">
<h2>Be suspicious of every <code>div</code></h2>
<dl>
<dt>MDN Glossary - Semantics</dt>
<dd>
<a href="https://developer.mozilla.org/en-US/docs/Glossary/Semantics#semantics_in_html">
https://developer.mozilla.org/en-US/docs/Glossary/Semantics#semantics_in_html
</a>
</dd>
</dt>
<strong>
<dt>MDN HTML Elements</dt>
<dd>
<a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element">
https://developer.mozilla.org/en-US/docs/Web/HTML/Element
</a>
</dd>
</strong>
<dt>Softwire Tech Talks - Digital Accessibility</dt>
<dd>
<a href="https://soundcloud.com/softwire_techtalks/digital-accessibility">
https://soundcloud.com/softwire_techtalks/digital-accessibility
</a>
</dd>
<dt>Slides</dt>
<dd><a href="http://swift.swifteagle.co.uk/semantics.html">http://swift.swifteagle.co.uk/semantics.html</a></dd>
</dl>
</section>
</article>
<script>
const slides = document.getElementsByClassName('slide')
const identifiers = [...slides].map(slide => slide.id)
const listener = ({ key }) => {
const slideIndex = Math.max(identifiers.indexOf(window.location.hash.substring(1)), 0)
const newIndex = ({
Home: 0,
ArrowLeft: Math.max(slideIndex - 1, 0),
ArrowRight: Math.min(slideIndex + 1, identifiers.length - 1),
End: identifiers.length - 1,
})[key]
if (newIndex == null) {
return
}
const newIdentifier = identifiers[newIndex]
if (!newIdentifier) {
return
}
window.location.href = '#' + newIdentifier
}
window.addEventListener('keyup', listener)
</script>
</body>
</html>