-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMarkup_Example.html
executable file
·180 lines (174 loc) · 5.43 KB
/
Markup_Example.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Form Example</title>
<link
rel="stylesheet"
href="Markup_Example_files/highlight/styles/default.css"
/>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/styles/default.min.css"
/>
<link rel="stylesheet" href="Markup_Example_files/main.css" />
<script src="Markup_Example_files/highlight/highlight.pack.js"></script>
<script>
hljs.initHighlightingOnLoad();
</script>
</head>
<body>
<h1>Sample Form</h1>
<form>
<h2>Entering text</h2>
<fieldset>
<legend>Contact Information</legend>
<div class="example">
<div class="output">
<label for="name">Name</label>
<br />
<input type="text" id="name" />
</div>
<pre
class="input"
><code class="html"><label for="name">Name</label>
<input type="text" id="name"/></code></pre>
</div>
<div class="example">
<div class="output">
<div id="address">Street Address</div>
<input type="text" aria-labelledby="address" />
</div>
<pre
class="input"
><code class="html"><div id="address">Street Address</div>
<input type="text" aria-labelledby="address"/></code></pre>
</div>
</fieldset>
<h2>Three ways to implement a checkbox</h2>
<ol>
<li>
<div class="example">
<div class="output">
<div class="custom-checkbox">
<!-- Simplest and most accessible -->
<input
type="checkbox"
id="agreeCheckbox"
class="scroll-on-focus"
/>
<label for="agreeCheckbox"
>I agree to the terms of service</label
>
</div>
</div>
<pre
class="input"
><code class="html"><!-- Simplest and most accessible -->
<label for="agreeCheckbox">
I agree to the terms of service
</label>
<input type="checkbox" id="agreeCheckbox"/></code></pre>
</div>
</li>
<li>
<div class="example">
<div class="output">
<!-- Not very accessible -->
<div
id="fake-checkbox-control"
class="fake-checkbox"
onclick="fakeCheckboxClick()"
>
<span class="checkbox" id="fake-checkbox"></span>
<span class="label">I agree to the terms of service</span>
</div>
</div>
<pre><code class="html"><!-- Not very accessible -->
<div onclick="fakeCheckboxClick()">
<span class="checkbox"></span>
<span class="label">I agree to the terms of service</span>
</div>
<script>
function fakeCheckboxClick() {
var checkbox = document.getElementById('fake-checkbox');
checkbox.classList.toggle('checked');
}
</script></code></pre>
</div>
</li>
<li>
<div class="example">
<div class="output">
<!-- More complex, more accessible -->
<div
id="fake-checkbox-control-aria"
class="fake-checkbox"
onclick="ariaCheckboxClick()"
>
<span
id="fake-checkbox-aria"
class="checkbox scroll-on-focus"
role="checkbox"
aria-labelledby="aria-checkbox-label"
tabindex="0"
></span>
<span class="label" id="aria-checkbox-label"
>I agree to the terms of service</span
>
</div>
</div>
<pre><code class="html"><!-- More complex, more accessible -->
<div onclick="ariaCheckboxClick()">
<span
id="fake-checkbox-aria"
role="checkbox"
aria-labelledby="aria-checkbox-label"
tabindex="0"
></span>
<span class="label" id="aria-checkbox-label">
I agree to the terms of service
</span>
</div>
<script>
function ariaCheckboxClick() {
var checkbox = document.getElementById('fake-checkbox-aria');
checkbox.classList.toggle('checked');
checkbox.setAttribute(
'aria-checked',
checkbox.classList.contains('checked')
);
}
</script></code></pre>
</div>
</li>
</ol>
<h2>Aria alerts</h2>
<div class="example">
<div class="output">
<button type="button" onclick="register()" class="scroll-on-focus btn btn-primary">
Register
</button>
<div id="alertDiv" role="alert"></div>
</div>
<pre
class="input"
><code><button type="button" onclick="register()">
Register
</button>
<div id="alertDiv" role="alert"></div>
<script>
function register() {
var alertDiv = document.getElementById('alertDiv');
var nameElt = document.getElementById('name');
alertDiv.innerText = (
'Thanks for registering, ' +
nameElt.value + '!'
);
}
</script></code></pre>
</div>
</form>
<script src="Markup_Example_files/main.js"></script>
</body>
</html>