Browser support determines whether a CSS property, JavaScript API, or HTML feature will work correctly in different web browsers. Understanding compatibility is crucial for building websites that work for all users.
// Check if Fetch API is supported
if (window.fetch) {
// Use Fetch API
fetch('/api/data')
.then(response => response.json())
.then(data => console.log(data));
} else {
// Fallback to XMLHttpRequest
var xhr = new XMLHttpRequest();
xhr.open('GET', '/api/data');
xhr.send();
}
/* Fallback for browsers without CSS Grid */
.container {
display: flex; /* Fallback */
flex-wrap: wrap;
}
/* Modern browsers with Grid support */
@supports (display: grid) {
.container {
display: grid;
grid-template-columns: repeat(3, 1fr);
}
}
Polyfills are scripts that provide modern functionality to older browsers:
<!-- Fetch API Polyfill -->
<script src="https://cdn.jsdelivr.net/npm/whatwg-fetch@3.6.2/dist/fetch.umd.js"></script>
| Feature | Modern Support | Notes |
|---|---|---|
| CSS Flexbox | Excellent (95%+) | Fully supported in all modern browsers |
| CSS Grid | Excellent (95%+) | IE11 has partial support with prefixes |
| CSS Variables | Very Good (90%+) | Not supported in IE11 |
| Fetch API | Very Good (95%+) | Polyfill recommended for IE11 |
| WebP Images | Very Good (95%+) | Use with fallbacks for older browsers |