Choosing Flexbox Implementation for Internet Explorer 10: Prefixed Syntax vs Fallbacks
Learn how to decide whether to use IE10’s prefixed -ms-flexbox, a float fallback, or -ms-grid, see a compact trade‑off table, and get a working implementation with feature detection and validation steps.
18 Aug 2025, 14:24 UTC

Decision: Use CSS Flexbox in IE10 or select a fallback
When building a responsive layout that must work in Internet Explorer 10, the only native flexbox support comes through the vendor‑prefixed -ms- properties. The unprefixed display:flex is ignored, so you must decide whether to rely on those prefixed rules, combine them with a fallback, or avoid flexbox entirely. The useful takeaway is: use the -ms- flexbox syntax for modern‑looking layouts, guard it with simple feature detection, and provide a float‑ or -ms-grid-based fallback for cases where the prefixed implementation fails or for older browsers.
Options Comparison
| Option | Description | Pros | Cons | When to use |
|---|---|---|---|---|
Native -ms- flexbox | Apply display:-ms-flexbox and related -ms-flex-* properties to a block‑level container. | Provides true flex behavior without JavaScript overhead; layout engine handles wrapping, alignment, and sizing. | Only works in IE10; known issues with percentage‑based flex-basis and flex-grow; ignored by modern browsers. | Primary layout for IE10 when you need wrapping, vertical centering, or order control. |
| Float‑based fallback | Use float:left (or right) with width percentages and optional clearfix to mimic a row. | Works in every browser; simple to understand; no prefixed syntax needed. | Lacks vertical alignment, order flexibility, and automatic wrapping when items exceed container width; requires manual clearing. | Simple toolbars, image galleries, or cases where only horizontal stacking is needed. |
-ms-grid layout | IE10’s proprietary grid module: display:-ms-grid with column/row definitions. | Can create complex two‑dimensional layouts without flexbox; still a native CSS solution. | Verbose syntax; limited to IE10/IE11; not a standard, so future‑proofing is poor. | When you need a fixed‑grid structure (e.g., a dashboard) and flexbox’s wrapping behavior is not required. |
| JavaScript polyfill (e.g., flexibility.js) | A script that reads standard display:flex rules and recreates the layout using script‑driven measurements. | Allows you to write standard flexbox code and still support IE10. | Adds runtime overhead, can cause layout thrashing, and may fail with dynamic content or CSS transitions. | Only if you cannot modify the CSS and must keep a single codebase; otherwise prefer native prefixed approach. |
Trade‑offs
The prefixed -ms- flexbox gives the closest experience to the standard spec while avoiding the performance cost of a polyfill. Its main drawbacks are the browser‑specific nature and a few flexbugs (e.g., percentage‑based flex-basis can cause unexpected collapsing). Float fallbacks are safe but sacrifice the vertical alignment and order capabilities that often motivate the use of flexbox. -ms-grid solves some of those limitations but introduces a non‑standard syntax that will not work in any other browser. A JavaScript polyfill removes the need to maintain two CSS sets but brings runtime risk and is generally discouraged for static layouts.
Implementation: Using -ms- flexbox with feature detection
Below is a minimal, copy‑paste‑ready example that shows how to serve the prefixed rules only to IE10 (and IE11) while letting modern browsers use the standard display:flex. The detection relies on the presence of the msFlexWrap property in the element’s style object.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>IE10 Flexbox Demo</title>
<style>
/* Base styles for all browsers */
.container {
margin: 1em;
padding: 1em;
background: #f9f9f9;
}
.item {
background: #4a90e2;
color: white;
padding: 0.5em;
margin: 0.5em;
text-align: center;
flex: 1 1 120px; /* grow, shrink, basis */
}
/* IE10/IE11 specific rules – injected via JS */
Place the HTML file on a web server or open it directly from disk. The script runs with the privileges of the page; no elevated permissions are required.
Validation and Practical Checks
- Open the file in Internet Explorer 10 (press F12 to launch Developer Tools).
- Select the container element (
#flexContainer) in the DOM tree. - In the Computed tab, verify that
displayshows-ms-flexboxand thatms-flex-directionisrowandms-flex-wrapiswrap. - Check that each child element lists
ms-flexwith the value1 1 120px. - Resize the IE10 window horizontally. The items should wrap to a new line when the container width drops below roughly five times the item basis (≈600 px).
- Open the same file in a modern browser (Chrome, Firefox, Edge). The layout should appear identical because the detection script does not run, and the standard
display:flexrules (inherited from the base.itemstyle) take effect.
If the items do not wrap or align as expected, double‑check that the container is a block‑level element (the default div is block). Inline containers will not generate a flex formatting context in IE10.
Limitations
- Percentage‑based
flex-basisorflex-growvalues can trigger the known IE10 flexbug, causing items to collapse or overflow. Use fixed pixel bases or theflex: 1 1 autoshorthand where possible. - The
-ms-prefixed properties are ignored by all non‑IE browsers, so the feature detection block is essential to avoid sending useless rules to modern browsers. - Flexbox in IE10 only applies to block‑level containers; applying it to an
spanor other inline element will have no effect.
Rollback
This approach does not alter any persistent state; it only adds CSS rules at runtime. If you need to revert, simply remove the detection script or comment out the block that sets the -ms- styles, and the page will fall back to the float‑based layout defined in your stylesheet.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.