Enterprise Skill for advanced development
HTML5 Semantic Markup & CSS Best Practices with Accessibility Focus
Primary Agent: ui-ux-expert Secondary Agent: frontend-expert Version: 1.0.0 Keywords: html, semantic html, html5, css, styling, accessibility, a11y, wcag, responsive, semantics
HTML Semantic Elements form the foundation of accessible, SEO-friendly web pages:
| Element | Purpose | Use Case |
|---|---|---|
<header> | Page/section header | Logo, navigation, branding |
<nav> | Navigation container | Menu, breadcrumbs, site links |
<main> |
| Primary content |
| Main page content (only one per page) |
<section> | Thematic content group | Articles, chapters, topics |
<article> | Self-contained content | Blog posts, news articles, comments |
<aside> | Tangentially related content | Sidebars, ads, related links |
<footer> | Footer section | Copyright, links, metadata |
CSS Best Practices:
!important)WCAG 2.1 AA Accessibility Checklist:
<div> for buttons)<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Accessible Web Page</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<!-- Page Header -->
<header role="banner">
<nav role="navigation" aria-label="Main navigation">
<a href="/" class="logo">Brand</a>
<ul>
<li><a href="/about">About</a></li>
<li><a href="/services">Services</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
</nav>
</header>
<!-- Skip Link (accessibility best practice) -->
<a href="#main" class="sr-only">Skip to main content</a>
<!-- Main Content -->
<main id="main" role="main">
<!-- Article Section -->
<article>
<h1>Article Title</h1>
<p>Article introduction...</p>
<section>
<h2>Section Heading</h2>
<p>Section content...</p>
</section>
</article>
<!-- Sidebar -->
<aside aria-label="Related content">
<h3>Related Articles</h3>
<ul>
<li><a href="...">Related article 1</a></li>
<li><a href="...">Related article 2</a></li>
</ul>
</aside>
</main>
<!-- Page Footer -->
<footer role="contentinfo">
<p>© 2025 Company Name. All rights reserved.</p>
</footer>
</body>
</html>
<!-- WCAG 2.1 AA Compliant Form -->
<form method="POST" action="/submit">
<fieldset>
<legend>Contact Information</legend>
<!-- Email Input with Label -->
<div class="form-group">
<label for="email">Email Address *</label>
<input
id="email"
type="email"
name="email"
required
aria-required="true"
aria-describedby="email-help"
>
<small id="email-help">We'll never share your email</small>
</div>
<!-- Text Area -->
<div class="form-group">
<label for="message">Message *</label>
<textarea
id="message"
name="message"
rows="5"
required
aria-required="true"
></textarea>
</div>
<!-- Error Message (live region) -->
<div role="alert" aria-live="polite" id="form-error">
<!-- Error messages inserted here -->
</div>
<!-- Submit Button -->
<button type="submit" class="btn btn-primary">
Send Message
</button>
</fieldset>
</form>
/* Design Tokens as CSS Custom Properties */
:root {
/* Colors */
--color-primary: #0ea5e9;
--color-primary-dark: #0284c7;
--color-secondary: #8b5cf6;
--color-neutral-900: #111827;
--color-neutral-500: #6b7280;
--color-neutral-100: #f3f4f6;
/* Typography */
--font-family-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
--font-family-mono: "Monaco", "Menlo", "Ubuntu Mono", monospace;
--font-size-sm: 0.875rem;
--font-size-base: 1rem;
--font-size-lg: 1.125rem;
--font-size-xl: 1.25rem;
--font-size-2xl: 1.5rem;
--font-weight-normal: 400;
--font-weight-medium: 500;
--font-weight-bold: 700;
/* Spacing (8px base unit) */
--spacing-xs: 0.25rem;
--spacing-sm: 0.5rem;
--spacing-md: 1rem;
--spacing-lg: 1.5rem;
--spacing-xl: 2rem;
--spacing-2xl: 3rem;
/* Breakpoints */
--breakpoint-sm: 640px;
--breakpoint-md: 768px;
--breakpoint-lg: 1024px;
--breakpoint-xl: 1280px;
/* Shadows */
--shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
--shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
--shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}
/* Base Styles */
html {
scroll-behavior: smooth;
}
body {
font-family: var(--font-family-sans);
font-size: var(--font-size-base);
color: var(--color-neutral-900);
line-height: 1.5;
-webkit-font-smoothing: antialiased;
}
/* Typography */
h1, h2, h3, h4, h5, h6 {
font-weight: var(--font-weight-bold);
line-height: 1.2;
}
h1 {
font-size: var(--font-size-2xl);
margin-bottom: var(--spacing-lg);
}
h2 {
font-size: var(--font-size-xl);
margin-bottom: var(--spacing-md);
}
p {
margin-bottom: var(--spacing-md);
}
/* Button Component */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
padding: var(--spacing-sm) var(--spacing-md);
font-weight: var(--font-weight-medium);
border: none;
border-radius: 0.375rem;
cursor: pointer;
transition: all 0.2s ease;
/* Focus indicator (WCAG AA) */
outline: none;
}
.btn:focus-visible {
outline: 2px solid var(--color-primary);
outline-offset: 2px;
}
.btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.btn-primary {
background-color: var(--color-primary);
color: white;
}
.btn-primary:hover {
background-color: var(--color-primary-dark);
}
/* Form Group */
.form-group {
margin-bottom: var(--spacing-lg);
}
label {
display: block;
font-weight: var(--font-weight-medium);
margin-bottom: var(--spacing-sm);
}
input, textarea, select {
width: 100%;
padding: var(--spacing-sm) var(--spacing-md);
border: 1px solid var(--color-neutral-300);
border-radius: 0.375rem;
font-family: inherit;
font-size: inherit;
}