Browser Technologies
Modern browser technologies have evolved into a comprehensive platform for building native-quality web applications. This skill covers HTML5, CSS (2025 standards), Progressive Web Apps, and Browser APIs.
Core Principles
- Progressive Enhancement: Build baseline experiences that work everywhere, then layer advanced features
- Feature Detection Over Browser Sniffing: Use
'feature' in navigator or @supports queries
- Secure Contexts: Most powerful features require HTTPS (or localhost for development)
- User Consent: Hardware and location APIs require explicit permission prompts
- Performance First: Use compositor-thread features (CSS animations, scroll-driven animations) over main-thread JavaScript
- Accessibility by Default: Semantic HTML + ARIA only when needed; never replace native elements
- Container Queries for Components: Use media queries for page layout, container queries for component responsiveness
- CSS Custom Properties as Bridges: Share state between JS and CSS via
--custom-properties
- Offline-First for PWAs: Design for network failure; use Service Workers for resilient experiences
- Sandbox vs. System: OPFS for hidden app data, File System Access API for user files
Quick Reference
HTML5 Essentials
<!-- Popover API (native top-layer management) -->
<button popovertarget="menu">Open</button>
<div id="menu" popover>Content</div>
<!-- Dialog (modal & non-modal) -->
<dialog id="modal">
<button
</dialog>
<script>document.getElementById('modal').showModal()</script>
<!-- Native details/summary (accordion) -->
<details>
<summary>Click to expand</summary>
<p>Hidden content</p>
</details>
CSS Modern Layout
/* Container Queries (component-aware) */
.wrapper {
container-type: inline-size;
container-name: card-container;
}
@container card-container (min-width: 400px) {
.card { flex-direction: row; }
}
/* Grid with auto-responsive columns */
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 1rem;
}
/* Scroll-Driven Animation */
@keyframes fade-in {
from { opacity: 0; }
to { opacity: 1; }
}
.element {
animation: fade-in linear;
animation-timeline: scroll();
}
Progressive Web Apps
// Service Worker Registration
if ('serviceWorker' in navigator) {
await navigator.serviceWorker.register('/sw.js');
}
// Install Prompt
let deferredPrompt;
window.addEventListener('beforeinstallprompt', (e) => {
e.preventDefault();
deferredPrompt = e;
});
// Web Push Notifications
const permission = await Notification.requestPermission();
const registration = await navigator.serviceWorker.ready;
const subscription = await registration.pushManager.subscribe({
userVisibleOnly: true,
applicationServerKey: urlBase64ToUint8Array(vapidPublicKey)
});
Topics
Core Technologies
- HTML Standards - Semantic elements, ARIA, forms, media, Popover API
- CSS Modern Features - Grid, Flexbox, Container Queries, Animations, Cascade Layers
- Progressive Web Apps - Service Workers, Manifest, Installation, Offline capabilities
Browser APIs
Integration Patterns
Common Patterns
Feature Detection Wrapper
const BrowserFeatures = {
// Check for API support
has(feature) {
const checks = {
serviceWorker: 'serviceWorker' in navigator,
geolocation: 'geolocation' in navigator,
fileSystemAccess: 'showOpenFilePicker' in window,
webShare: 'share' in navigator,
containerQueries: CSS.supports('container-type: inline-size'),
viewTransitions: 'startViewTransition' in document
};
return checks[feature] ?? false;
},
// Graceful degradation
async fileOperation(content) {
if (this.has('fileSystemAccess')) {
// Chromium: Direct file access
const handle = await window.showSaveFilePicker();
const writable = await handle.createWritable();
await writable.write(content);
await writable.close();
} else {
// Fallback: Blob download
const blob = new Blob([content], {type: 'text/plain'});
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'file.txt';
a.click();
}
}
};
Responsive Component (Container Query)
/* Define container */
.card-wrapper {
container-type: inline-size;
container-name: card;
}
/* Mobile-first base */
.card {
display: flex;
flex-direction: column;
gap: 1rem;
}
/* Container-based breakpoints */
@container card (min-width: 400px) {
.card {
flex-direction: row;
}
}
@container card (min-width: 600px) {
.card {
padding: 2cqi; /* Container query units */
}
}
Browser Support Strategy
Baseline Features (98%+ support - 2025)
- Service Workers, Web App Manifest, Web Push
- CSS Grid, Flexbox, Custom Properties
- Container Queries (size-based)
- localStorage, sessionStorage
- Canvas 2D, Geolocation
- Popover API, Dialog element
Chromium-Exclusive (Chrome/Edge only)
- File System Access API (device-level)
- Web Bluetooth, Web USB, Web Serial
- Multi-Screen Window Placement
- Protocol Handlers (full integration)
Progressive Enhancement Pattern
// Always provide fallback
if (BrowserFeatures.has('webShare')) {
button.onclick = async () => {
await navigator.share({ title, text, url });
};
} else {
button.onclick = () => {
navigator.clipboard.writeText(url);
showToast('Link copied!');
};
}
Resources
1---2name: browser-33description: Expert knowledge for modern browser technologies including HTML5, CSS (Grid, Flexbox, Container Queries, Scroll-Driven Animations, Anchor Positioning), Progressive Web Apps (PWA, Service Workers, Web Push, File System Access), and Browser APIs (Canvas, Geolocation, Web Storage, Web Share, Drag and Drop). Use when working with web standards, client-side features, responsive design, offline capabilities, or native-like web experiences.4---5
6# Browser Technologies
7
8Modern browser technologies have evolved into a comprehensive platform for building native-quality web applications. This skill covers HTML5, CSS (2025 standards), Progressive Web Apps, and Browser APIs.
9
10## Core Principles
11
12- **Progressive Enhancement**: Build baseline experiences that work everywhere, then layer advanced features
13- **Feature Detection Over Browser Sniffing**: Use `'feature' in navigator` or `@supports` queries
14- **Secure Contexts**: Most powerful features require HTTPS (or localhost for development)
15- **User Consent**: Hardware and location APIs require explicit permission prompts
16- **Performance First**: Use compositor-thread features (CSS animations, scroll-driven animations) over main-thread JavaScript
17- **Accessibility by Default**: Semantic HTML + ARIA only when needed; never replace native elements
18- **Container Queries for Components**: Use media queries for page layout, container queries for component responsiveness
19- **CSS Custom Properties as Bridges**: Share state between JS and CSS via `--custom-properties`
20- **Offline-First for PWAs**: Design for network failure; use Service Workers for resilient experiences
21- **Sandbox vs. System**: OPFS for hidden app data, File System Access API for user files
22
23## Quick Reference
24
25### HTML5 Essentials
26
27```html
28<!-- Popover API (native top-layer management) -->
29<button popovertarget="menu">Open</button>
30<div id="menu" popover>Content</div>
31
32<!-- Dialog (modal & non-modal) -->
33<dialog id="modal">
34 <button onclick="this.closest('dialog').close()">Close</button>
35</dialog>
36<script>document.getElementById('modal').showModal()</script>
37
38<!-- Native details/summary (accordion) -->
39<details>
40 <summary>Click to expand</summary>
41 <p>Hidden content</p>
42</details>
43```
44
45### CSS Modern Layout
46
47```css
48/* Container Queries (component-aware) */
49.wrapper {
50 container-type: inline-size;
51 container-name: card-container;
52}
53
54@container card-container (min-width: 400px) {
55 .card { flex-direction: row; }
56}
57
58/* Grid with auto-responsive columns */
59.grid {
60 display: grid;
61 grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
62 gap: 1rem;
63}
64
65/* Scroll-Driven Animation */
66@keyframes fade-in {
67 from { opacity: 0; }
68 to { opacity: 1; }
69}
70
71.element {
72 animation: fade-in linear;
73 animation-timeline: scroll();
74}
75```
76
77### Progressive Web Apps
78
79```javascript
80// Service Worker Registration
81if ('serviceWorker' in navigator) {
82 await navigator.serviceWorker.register('/sw.js');
83}
84
85// Install Prompt
86let deferredPrompt;
87window.addEventListener('beforeinstallprompt', (e) => {
88 e.preventDefault();
89 deferredPrompt = e;
90});
91
92// Web Push Notifications
93const permission = await Notification.requestPermission();
94const registration = await navigator.serviceWorker.ready;
95const subscription = await registration.pushManager.subscribe({
96 userVisibleOnly: true,
97 applicationServerKey: urlBase64ToUint8Array(vapidPublicKey)
98});
99```
100
101## Topics
102
103### Core Technologies
104
105- [HTML Standards](./html.md) - Semantic elements, ARIA, forms, media, Popover API
106- [CSS Modern Features](./css.md) - Grid, Flexbox, Container Queries, Animations, Cascade Layers
107- [Progressive Web Apps](./pwa.md) - Service Workers, Manifest, Installation, Offline capabilities
108
109### Browser APIs
110
111- [Web Storage](./web-storage.md) - localStorage, sessionStorage, IndexedDB strategy
112- [File System Access](./file-system.md) - OPFS vs. device-level access, security model
113- [Canvas & Graphics](./canvas.md) - 2D context, WebGL, OffscreenCanvas
114- [Geolocation](./geolocation.md) - getCurrentPosition, watchPosition, accuracy handling
115- [Web Share](./web-share.md) - Native share dialog integration
116- [Drag and Drop](./drag-drop.md) - DataTransfer API, accessibility considerations
117
118### Integration Patterns
119
120- [HTML-JavaScript Interaction](./html-js-interaction.md) - DOM manipulation, event handling
121- [CSS-JavaScript Interaction](./css-js-interaction.md) - Custom properties, View Transitions, Houdini
122
123## Common Patterns
124
125### Feature Detection Wrapper
126
127```javascript
128const BrowserFeatures = {
129 // Check for API support
130 has(feature) {
131 const checks = {
132 serviceWorker: 'serviceWorker' in navigator,
133 geolocation: 'geolocation' in navigator,
134 fileSystemAccess: 'showOpenFilePicker' in window,
135 webShare: 'share' in navigator,
136 containerQueries: CSS.supports('container-type: inline-size'),
137 viewTransitions: 'startViewTransition' in document
138 };
139 return checks[feature] ?? false;
140 },
141
142 // Graceful degradation
143 async fileOperation(content) {
144 if (this.has('fileSystemAccess')) {
145 // Chromium: Direct file access
146 const handle = await window.showSaveFilePicker();
147 const writable = await handle.createWritable();
148 await writable.write(content);
149 await writable.close();
150 } else {
151 // Fallback: Blob download
152 const blob = new Blob([content], {type: 'text/plain'});
153 const url = URL.createObjectURL(blob);
154 const a = document.createElement('a');
155 a.href = url;
156 a.download = 'file.txt';
157 a.click();
158 }
159 }
160};
161```
162
163### Responsive Component (Container Query)
164
165```css
166/* Define container */
167.card-wrapper {
168 container-type: inline-size;
169 container-name: card;
170}
171
172/* Mobile-first base */
173.card {
174 display: flex;
175 flex-direction: column;
176 gap: 1rem;
177}
178
179/* Container-based breakpoints */
180@container card (min-width: 400px) {
181 .card {
182 flex-direction: row;
183 }
184}
185
186@container card (min-width: 600px) {
187 .card {
188 padding: 2cqi; /* Container query units */
189 }
190}
191```
192
193## Browser Support Strategy
194
195### Baseline Features (98%+ support - 2025)
196- Service Workers, Web App Manifest, Web Push
197- CSS Grid, Flexbox, Custom Properties
198- Container Queries (size-based)
199- localStorage, sessionStorage
200- Canvas 2D, Geolocation
201- Popover API, Dialog element
202
203### Chromium-Exclusive (Chrome/Edge only)
204- File System Access API (device-level)
205- Web Bluetooth, Web USB, Web Serial
206- Multi-Screen Window Placement
207- Protocol Handlers (full integration)
208
209### Progressive Enhancement Pattern
210
211```javascript
212// Always provide fallback
213if (BrowserFeatures.has('webShare')) {
214 button.onclick = async () => {
215 await navigator.share({ title, text, url });
216 };
217} else {
218 button.onclick = () => {
219 navigator.clipboard.writeText(url);
220 showToast('Link copied!');
221 };
222}
223```
224
225## Resources
226
227- [WHATWG HTML Living Standard](https://html.spec.whatwg.org/)
228- [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web)
229- [Can I Use](https://caniuse.com/)
230- [W3C WAI-ARIA](https://www.w3.org/WAI/standards-guidelines/aria/)
231- [Web.dev](https://web.dev/)
232- [Chrome Platform Status](https://chromestatus.com/)