-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path12-Accessibility (A11Y) + Best Practices.html
More file actions
98 lines (78 loc) · 2.19 KB
/
12-Accessibility (A11Y) + Best Practices.html
File metadata and controls
98 lines (78 loc) · 2.19 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<!-- Mobile Friendly -->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>12 – Accessibility (A11Y) + Best Practices | JDCodebase</title>
<!-- Basic SEO -->
<meta
name="description"
content="Learn HTML Accessibility (A11Y) best practices including alt text, ARIA roles, keyboard navigation, semantic tags, and screen reader support."
/>
<style>
button {
padding: 10px 18px;
cursor: pointer;
}
.fake-btn {
border: 2px solid #333;
padding: 10px 18px;
display: inline-block;
}
/* Focus visible styles */
:focus {
outline: 3px solid blue;
}
</style>
</head>
<body>
<header>
<h1>Accessibility in HTML (A11Y)</h1>
</header>
<main>
<!-- Images Accessibility -->
<section>
<h2>Accessible Images</h2>
<!-- Meaningful Image -->
<img src="assets/car.webp" alt="Red sports car parked on a road" />
<!-- Decorative Image (No Meaning) -->
<img src="assets/dog.webp" alt="" />
</section>
<!-- Buttons & ARIA -->
<section>
<h2>Buttons & ARIA</h2>
<!-- Screen Reader Label -->
<button aria-label="Close menu">X</button>
<!-- ❌ Wrong: div should not be a button -->
<div class="fake-btn" role="button" tabindex="0">
Click me (not recommended)
</div>
<!-- ✅ Correct -->
<button>Click me</button>
<!-- Keyboard Accessible -->
<button tabindex="0">Submit</button>
</section>
<!-- Semantic Structure -->
<section>
<h2>Semantic Structure Example</h2>
<header>
<h3>JDCodebase Website</h3>
</header>
<nav>
<a href="#">Home</a>
<a href="#">About</a>
</nav>
<main>
<section>
<h3>Accessibility</h3>
<p>Learn HTML A11Y basics with examples</p>
</section>
</main>
<footer>
<p>© 2025 JDCodebase</p>
</footer>
</section>
</main>
</body>
</html>