html
๐ฏSkillfrom jaredlander/freshbooks-speed
Crafts semantic, accessible, and performant HTML pages using modern web standards and best practices.
Installation
npx html-validate src/**/*.htmlSkill Details
Write semantic, accessible, performant HTML with modern best practices. Use when asked to (1) create HTML pages or documents, (2) write semantic markup, (3) improve accessibility, (4) optimize HTML structure and performance, (5) implement forms, tables, or complex layouts, or when phrases like "HTML page", "web page", "markup", "semantic HTML", "accessibility" appear.
Overview
# Expert HTML Development
Write clean, semantic, accessible HTML that follows modern web standards and best practices.
MCP Integration - Context7
CRITICAL: Before writing or editing ANY HTML code, ALWAYS use the Context7 MCP server to check for relevant context.
Context7 provides access to a knowledge base that may contain:
- Project-specific HTML patterns and conventions
- Custom component libraries and templates
- Style guide requirements
- Accessibility standards for the project
- Performance benchmarks and requirements
- Team preferences and coding standards
Workflow:
- Before writing code: Query Context7 for relevant patterns, conventions, or examples
- During editing: Check Context7 for project-specific requirements that might affect your changes
- After writing: Verify your code aligns with any Context7 guidance
Use Context7 to search for topics like:
- "HTML conventions"
- "accessibility requirements"
- "component templates"
- "form patterns"
- "performance standards"
- Specific component or pattern names
Never skip the Context7 check - it ensures your HTML aligns with project standards and leverages existing patterns.
Core Principles
- Semantic first - Use elements for their intended meaning, not just appearance
- Accessibility by default - Every user deserves a great experience
- Progressive enhancement - Start with working HTML, layer on CSS/JS
- Performance matters - Optimize for speed and efficiency
Document Structure
Minimal Valid HTML5 Document
```html
```
Essential Meta Tags
```html
```
Semantic HTML Elements
Use the Right Element for the Job
```html
Article Title
Article content...
```
Sectioning Elements
| Element | Purpose | When to Use |
|---------|---------|-------------|
| | Introductory content | Site/section header, not just "top of page" |
| | Navigation links | Primary navigation, table of contents, breadcrumbs |
| | Primary content | One per page, skips to main content |
| | Self-contained content | Blog posts, news items, forum posts |
| | Thematic grouping | Chapters, tabs, themed sections (always has heading) |
| | Tangentially related | Sidebars, pull quotes, related links |
| | Footer content | Site/section footer, not just "bottom of page" |
Heading Hierarchy
```html
Page Title
Main Section
Subsection
Another Subsection
Another Main Section
Page Title
Skipped h2 and h3
```
Accessibility Best Practices
ARIA Labels and Roles
```html

๐ง
Email Address
```
Focus Management
```html
Custom Button
```
Alternative Text
```html



Detailed description of the network topology showing...


```
ARIA Live Regions
```html
Loading...
Error: Please correct the form errors below.
```
Forms
Accessible Form Structure
```html
type="text"
id="name"
name="name"
required
aria-required="true"
aria-describedby="name-hint"
autocomplete="name"
>
Enter your first and last name
type="email"
id="email"
name="email"
required
aria-required="true"
autocomplete="email"
aria-invalid="false"
>
Phone
Weekly Updates
Monthly Digest
id="message"
name="message"
rows="5"
maxlength="500"
aria-describedby="char-count"
>
0 / 500 characters
```
HTML5 Input Types
```html
```
Input Attributes for Better UX
```html
type="text"
name="username"
pattern="[a-zA-Z0-9_]{3,16}"
title="Username must be 3-16 characters, letters, numbers, and underscores only"
>
```
Tables
Accessible Data Tables
```html
Quarter Revenue Growth Q1 $1.2M +5% Q2 $1.5M +25% Total $2.7M +15%
Instructor Monday Tuesday Wednesday Dr. Smith Biology 101 Biology 201 Lab
```
Lists
Choosing the Right List Type
```html
```
Performance Optimization
Image Optimization
```html
src="image-800w.jpg"
srcset="
image-400w.jpg 400w,
image-800w.jpg 800w,
image-1200w.jpg 1200w,
image-1600w.jpg 1600w
"
sizes="(max-width: 600px) 100vw, (max-width: 1200px) 50vw, 800px"
alt="Descriptive alt text"
loading="lazy"
decoding="async"
width="800"
height="600"
>




```
Resource Loading Strategies
```html
/ Critical above-fold CSS /
```
HTML Size Optimization
```html
Some text here
Some text here
Text
Text
```
Modern HTML Features
Details and Summary (Native Disclosure)
```html
Hidden content that can be toggled.
Answer to the question.
```
Dialog Element (Native Modal)
```html
Dialog Title
Dialog content goes here.
Open Dialog
```
Data Attributes
```html
Article Title
```
Template Element
```html
const template = document.getElementById('item-template');
const clone = template.content.cloneNode(true);
// Populate and append
```
Content Embedding
Videos
```html
controls
width="640"
height="360"
poster="video-thumbnail.jpg"
preload="metadata"
>
kind="subtitles"
src="subtitles-en.vtt"
srclang="en"
label="English"
>
kind="captions"
src="captions-en.vtt"
srclang="en"
label="English CC"
default
>
Your browser doesn't support HTML5 video.
Download the video instead.
width="560"
height="315"
src="https://www.youtube.com/embed/VIDEO_ID"
title="Video Title for Accessibility"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen
loading="lazy"
>
```
Audio
```html
Your browser doesn't support HTML5 audio.
Download the audio instead.
```
Iframes
```html
src="https://example.com/embed"
title="Descriptive title for screen readers"
width="600"
height="400"
loading="lazy"
sandbox="allow-scripts allow-same-origin"
>
```
Validation and Quality
HTML Validation Checklist
- [ ] Valid DOCTYPE declaration
- [ ] Proper nesting (no overlapping tags)
- [ ] All tags properly closed
- [ ] Unique IDs on a page
- [ ] Valid attributes for each element
- [ ] Proper character encoding (UTF-8)
- [ ] Alt text for all images (or empty alt for decorative)
- [ ] Form labels associated with inputs
- [ ] Heading hierarchy (no skipped levels)
- [ ] Lang attribute on html tag
- [ ] Valid HTML5 (use W3C validator)
Common HTML Mistakes to Avoid
```html
First paragraph
Second paragraph
First paragraph
Second paragraph
Content
Content
Sidebar Main content
```
Security Best Practices
Progressive Enhancement
Build from HTML Up
```html
Content revealed when expanded.
details { border: 1px solid #ccc; padding: 1rem; }
summary { cursor: pointer; font-weight: bold; }
// Add analytics, animations, or custom behavior
document.querySelectorAll('details').forEach(detail => {
detail.addEventListener('toggle', () => {
if (detail.open) {
// Track expansion
}
});
});
```
Tools and Workflow
Recommended Tools
| Purpose | Tool | Why |
|---------|------|-----|
| Validation | [W3C Validator](https://validator.w3.org/) | Check HTML validity |
| Accessibility | [axe DevTools](https://www.deque.com/axe/) | Find a11y issues |
| Performance | [Lighthouse](https://developers.google.com/web/tools/lighthouse) | Audit performance |
| HTML Minification | [html-minifier](https://github.com/kangax/html-minifier) | Reduce file size |
| Linting | [HTMLHint](https://htmlhint.com/) | Catch common mistakes |
HTML in Build Pipelines
```bash
# Validate HTML
npx html-validate src/*/.html
# Minify HTML
npx html-minifier --collapse-whitespace --remove-comments input.html -o output.html
# Check accessibility
npx pa11y http://localhost:3000
```
Quick Reference
Common Character Entities
| Character | Entity | Numeric |
|-----------|--------|---------|
| < | < | < |
| > | > | > |
| & | & | & |
| " | " | " |
| ' | ' | ' |
| ยฉ | © | © |
| ยฎ | ® | ® |
| โข | ™ | ™ |
| non-breaking space | | |
| โ (em dash) | — | — |
| โ (en dash) | – | – |
Global Attributes
Available on all HTML elements:
id- Unique identifierclass- CSS class names (space-separated)style- Inline CSS stylestitle- Advisory information (tooltip)lang- Language of element contentdir- Text directionality (ltr, rtl, auto)hidden- Hide elementtabindex- Tab order (-1, 0, positive numbers)contenteditable- Make element editabledata-*- Custom data attributesdraggable- Enable drag and dropspellcheck- Enable spell checking
Best Practices Summary
- Always check Context7 MCP before writing/editing code - Leverage project-specific patterns and requirements
- Always use semantic HTML - Choose elements based on meaning, not appearance
- Validate your HTML - Use W3C validator to catch errors
- Prioritize accessibility - Use ARIA attributes, alt text, and keyboard navigation
- Optimize for performance - Lazy load images, defer scripts, minimize HTML
- Use progressive enhancement - Start with HTML, layer on CSS and JavaScript
- Keep it simple - Don't over-engineer with unnecessary divs and complexity
- Test across browsers - Ensure compatibility with all major browsers
- Think mobile-first - Design for small screens, enhance for larger ones
- Use meaningful names - IDs and classes should describe purpose, not appearance
- Comment sparingly - Code should be self-documenting, comments for complex logic only