CSS appearance Property Demo - Online Reset Native Styles
Reset native styling on form elements with appearance: none. See before and after. Essential for custom forms.
UD5 Toolkit
Explore element.attributeStyleMap — the typed, programmatic way to manipulate CSS
No properties set via attributeStyleMap yet.
Use Set or click a Preset above.
| Property | Type | Value |
|---|
element.style.width = '200px', you use typed objects such as CSSUnitValue, CSSMathValue, and CSSKeywordValue. The attributeStyleMap is a property on every DOM element that returns a StylePropertyMap — a Map-like object for getting and setting CSS properties using these typed values. It provides better performance, type safety, and eliminates string parsing.
| Feature | element.style | attributeStyleMap |
|---|---|---|
| Value format | Strings only | Typed objects (CSSUnitValue, etc.) |
| Type safety | None (string parsing) | Full type information preserved |
| Math operations | Requires calc() strings | CSSMathValue objects, programmatic |
| Iteration | Manual parsing | Map-like: for...of, entries(), keys() |
| Performance | String concat + reparse | Direct typed manipulation, faster |
| Browser support | Universal | Chrome 66+, Edge 79+, Opera 53+ |
new CSSUnitValue(200, 'px') or shorthand CSS.px(200). Properties: .value (number) and .unit (string).block, none, auto, or color names like red. Created via new CSSKeywordValue('block').CSSMathSum, CSSMathProduct, CSSMathMin, CSSMathMax, and CSSMathClamp. These enable programmatic calc()-like operations without string building.transform as an array of transform components like CSSTranslate, CSSRotate, CSSScale.if (typeof CSSUnitValue === 'function') or if (element.attributeStyleMap) and gracefully fall back to element.style for unsupported browsers.
--my-color) work seamlessly with attributeStyleMap. You can set them using element.attributeStyleMap.set('--my-color', new CSSKeywordValue('blue')) or with parsed values. This is particularly powerful because it allows type-safe manipulation of custom properties that might be consumed by other parts of your stylesheet via var(). Try the Custom Props preset in this playground to see it in action.
element.style requires converting between strings and internal typed representations repeatedly — every time you read a value, the browser serializes it to a string; every time you write, it parses the string back. With Typed OM, values stay in their typed representation, eliminating serialization and parsing overhead. For animation-heavy applications or frequent style updates (e.g., during scroll, pointer events, or Web Animations API usage), this can significantly reduce jank and improve frame rates. Google's benchmarks show up to ~30% faster style operations in some scenarios.
attributeStyleMap returns a StylePropertyMap (which behaves like a Map), you can iterate using standard patterns:
// Using for...of
for (const [prop, value] of element.attributeStyleMap) {
console.log(prop, value.toString(), value.constructor.name);
}
// Using entries()
for (const [prop, value] of element.attributeStyleMap.entries()) {
console.log(`${prop}: ${value}`);
}
// Using forEach
element.attributeStyleMap.forEach((value, prop) => {
console.log(prop, value);
});
You can also use .keys(), .values(), .has(prop), and .size.
border, margin, padding, background, and font represent multiple longhand properties simultaneously. The Typed OM generally requires you to use longhand properties (e.g., margin-top, border-left-width) when setting values via attributeStyleMap.set(). Attempting to set a shorthand may throw a TypeError. This is by design — it ensures type precision. The playground above primarily uses longhand properties for this reason. You can still get computed values of shorthands via element.computedStyleMap().get('margin') in some cases, but the returned value structure varies.
CSS.px(200) → CSSUnitValue {value: 200, unit: 'px'}CSS.em(1.5) → CSSUnitValue {value: 1.5, unit: 'em'}CSS.percent(80) → CSSUnitValue {value: 80, unit: '%'}CSS.deg(45) → CSSUnitValue {value: 45, unit: 'deg'}CSS.vw(50), CSS.vh(100), CSS.s(2)new CSSMathSum(CSS.px(100), CSS.px(50))new CSSMathProduct(CSS.px(10), 3)new CSSMathMin(CSS.px(100), CSS.px(200))new CSSMathMax(CSS.vw(50), CSS.px(300))new CSSMathClamp(CSS.px(50), CSS.px(100), CSS.px(200)).set(prop, CSSStyleValue) — Set a typed value.get(prop) — Returns CSSStyleValue or null.has(prop) — Returns boolean.delete(prop) — Remove a property.clear() — Remove all inline styles.size — Number of propertiesReset native styling on form elements with appearance: none. See before and after. Essential for custom forms.
Explore the new two‑value display syntax like `display: block flex`. See what each inner/outer pair does visually.
Write a fragment shader and see the result rendered on a full‑screen quad. For WebGL learners. Local compilation.
Write modern CSS color functions like oklch(), lab(), hwb() and see the rendered color with fallback. Copy compatible code.
Chain multiple CSS filter functions and see the result on an image. Copy the filter string. No upload.
Change all alignment and justification values and see the flex items move. Indispensable for learning Flexbox.
Drag a positioned box and see the top/right/bottom/left values change. Understand containing blocks. Visual.
Type text and instantly see it rendered with text‑transform: uppercase, lowercase, capitalize, and full‑width. Copy CSS.
Set perspective and rotate children in 3D space. See the effect of perspective‑origin. Copy the CSS. Learn 3D transforms.
Click on a box to set the transform‑origin point and see how rotations and scales change. Copy the CSS.
Drag items into grid cells and see the resulting grid‑area or line‑based placement code. Learn how auto‑placement and spanning work.
Drag to resize a box and see the Resize Observer callback fire. Get contentRect and borderBoxSize. Learn the API.
Write CSS like `oklch(from red l c h)` to modify colors. Preview the output and copy. Modern color manipulation.
Write JavaScript using element.animate() and see the result in a live preview. Compare with CSS keyframes. Debugger included.
Write compound selectors and instantly see which elements they match on a test page. Master complex CSS logic.
See every touch point with coordinates, radius, and force on your mobile device. Debug gestures with live overlay.
Write a compute shader in WGSL and run it in the browser. See the output on a canvas. Learn WebGPU. Real‑time compilation.
Write a paint worklet in JavaScript and see it used as a CSS background instantly. Experiment with Houdini. Local.
Type directly into a contenteditable div with real‑time CSS filters, shadows, and colors. Download as HTML. Fun demo.
Create an animation that advances with scroll using animation‑timeline: scroll(). See the visual timeline editor. Modern CSS.
Register and apply a custom paint worklet to draw a background pattern dynamically. Write the paint function in the browser.
Input any JavaScript object and see if structuredClone can deep‑copy it. Compare with JSON.parse/stringify. Learn transferables.
Write a pattern and test it against URLs instantly. See which groups match. Learn the modern alternative to regex for routing. Works entirely in the browser.
Write CSS with native nesting (like SCSS) and see the browser’s native parsing. Validator and live output.
Pick two images or colors and apply all 16 CSS mix‑blend‑mode values live. See and copy the right CSS for your design.
Experiment with the CSS color-mix() function. Pick two colors and mix them in different color spaces (srgb, oklch). Copy the CSS.
Interactively add and adjust multiple box shadows on a sample element. Drag sliders for offset, blur, spread, and color. Copy the clean CSS code instantly.
Drag points to create a custom clip‑path shape. See the CSS value update live. For creating non‑rectangular elements.
Experiment with CSS Grid properties visually. Add rows, columns, and areas. See the grid in action and copy the code.
Type any condition and see the result of the ternary operator. Understand truthy/falsy values. Quick learning tool.