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
contain Property Demo
Interactive visualization of layout, paint & size isolation in real-time
Observe how contain:size prevents the container from growing with its children.
contain:size, the container's height is dictated by its children. With it, the height collapses to 0 unless explicitly set.
See how contain:paint clips overflow and contain:layout contains floats.
This text wraps around the float. contain:layout creates a BFC and contains the float entirely.
contain:paint clips it. contain:layout makes the container self-contained for floats.
CSS contain tells the browser what the element's subtree is independent of, enabling powerful optimizations.
contain:layout creates a formatting context boundary. Internal layout changes don't trigger external reflows.
contain:paint acts like a super overflow:hidden â it also creates a stacking context and containing block.
contain:size lets the browser skip subtree size calculations â ideal for virtual scrolling & lazy-loaded widgets.
contain property and why should I use it?
contain property allows you to indicate that an element's subtree is independent from the rest of the page. This gives browsers critical hints to optimize rendering performance. By isolating layout, paint, or size calculations, the browser can skip expensive recalculations when only the contained subtree changes. It's one of the most impactful CSS properties for web performance, especially for complex UIs, widget-heavy pages, and infinite scroll implementations. Values include none, size, layout, paint, style, content (size+layout+paint), and strict (all four).
contain:paint and overflow:hidden?
contain:paint goes significantly further. It creates a new stacking context, establishes a containing block for absolutely positioned descendants, and acts as a paint boundary. This means the browser can paint the element independently â if it hasn't changed, its pixels can be reused from a cached layer. overflow:hidden only clips content without providing these additional isolation guarantees. For performance-critical rendering, contain:paint is the stronger choice.
contain:size work and when does the container collapse?
contain:size tells the browser that the element's size does not depend on its children. For block-level elements without an explicit height, the height collapses to 0 (padding and borders remain). The width typically remains 100% of the parent for block elements in normal flow. This is perfect for virtual scroll containers, lazy-loaded widgets with known dimensions, and carousel items where you want to pre-allocate space. Always set explicit width and height (or use content-visibility:auto which applies size containment automatically) when using contain:size to avoid unexpected collapsing.
contain:layout actually isolate?
contain:layout creates a formatting context boundary (similar to a BFC â Block Formatting Context). This means: (1) Internal layout changes (like a child growing) won't affect elements outside the container â no external reflow. (2) Floats inside the container are contained and won't escape. (3) Margin collapsing between the container's children and external elements is prevented. (4) The container acts as a baseline isolation point. It's ideal for independent UI components like modals, dropdown panels, and sidebar widgets where internal layout stability is desired.
contain and content-visibility?
content-visibility:auto is a powerful CSS property that automatically applies contain:size layout paint (equivalent to contain:content) to elements that are off-screen. This allows the browser to skip rendering work for off-screen content entirely, dramatically improving page load and scroll performance. You can think of contain as the low-level primitive, and content-visibility as the high-level, automated application of containment. Use contain for fine-grained control over always-visible elements, and content-visibility:auto for below-the-fold content sections.
contain value gives the best performance?
contain:strict applies all four containment types (size, layout, paint, style) and offers the maximum isolation. However, it's also the most restrictive. For most practical use cases, contain:content (equivalent to size layout paint) provides an excellent balance of performance and flexibility. It enables all major optimizations while being less restrictive than strict. The key is choosing the least restrictive value that still accurately describes your element's independence â over-containing can break layouts just as under-containing misses optimization opportunities.
contain safe to use on any element?
contain:size will collapse an element's height to 0 if no explicit height is set â this can break layouts unexpectedly. contain:paint creates a new stacking context which may affect z-index behavior. contain:layout affects how floats and margins interact. Always test thoroughly after applying containment. Start with contain:layout or contain:paint individually before combining them, and use browser DevTools to verify the element still renders as expected across all viewport sizes.
contain badge next to elements that have containment applied. In the Rendering tab (available via the three-dot menu â More tools â Rendering), you can enable "Layer borders" to visualize paint-contained layers. The Performance panel also shows reduced layout and paint work for contained elements. Firefox's DevTools similarly highlights containment in the inspector. When things look wrong, temporarily set contain:none to confirm whether containment is the culprit.
Reset native styling on form elements with appearance: none. See before and after. Essential for custom forms.
Swap between physical and logical properties (marginâinline vs marginâleft). Live preview with writingâmode. Internationalize your CSS.
Manipulate CSS values as typed objects using attributeStyleMap. Convert between CSSUnitValue, CSSMathSum, etc. Futuristic CSSâinâJS.
Understand @layer by visually ordering style layers and seeing which rules win. Fix specificity battles. Modern CSS architecture.
Create a frosted glass card with background blur, border glow, and shadow. Adjust intensity. Copy the CSS.
Define a set of colors for light and dark themes. Get the CSS custom properties snippet. Toggle live.
Access the Paint Timing API and display First Paint, First Contentful Paint, and Largest Contentful Paint times. Quick perf check.
Paste your stylesheet and get a clean list of all custom properties defined under :root. Copy the whole block. Local analysis.
Paste your CSS and see rules sorted by specificity. Find overrides and potential collisions. Understand your cascade.
Write slides in Markdown and instantly preview a webâbased presentation. Export as HTML. Pure frontend.
Implement a dark/light theme toggle that respects prefersâcolorâscheme. Copy the complete JavaScript and CSS.
Enter total balance and limit to see utilization percentage. See how it affects credit score bands.
Checklist for plein air painting gear based on medium (oil, watercolor, etc.). Don't forget anything.
List all resources loaded by the current page and their detailed timing breakdown. Inâbrowser waterfall.
Mix sodium hypochlorite with water to get the correct % concentration for soft washing. Safety note.
See how extra monthly or lumpâsum payments reduce your mortgage term and total interest. Dynamic chart. All local calculation.
Estimate curing time for UV resin based on lamp wattage and layer thickness. Avoid sticky finishes.
Enter a URL and instantly generate a PDF version using the browser's print-to-pdf engine. Private, no upload.
Enter your must volume and current Brix, TA, and pH to calculate additions of sugar, acid blend, or tannin. Standard winemaking formulas.
Enter a URL and instantly generate a PDF version using the browser's print-to-pdf engine. Private, no upload.
Estimate how long a battery will last given capacity (mAh/Wh) and load current. Also computes backup time for power banks. Quick and local.
Based on home and destination time zones, suggests a light exposure/avoidance schedule to reduce jet lag. Educational tool, local only.
See the current Service Worker registration, its state, and scope. Send 'skipWaiting' and update. PWA debug.
Calculate total work hours and pay from time-in/out entries. Supports overtime and breaks. Generate a printable timesheet. All local.
Click to get a random, unique superpower with a description. Perfect for character creation or daydreaming.
Connect to a BLE device and read its Battery Service characteristic. See the charge level in a gauge.
Enter network name and password to generate a stylish printable card for visitors. Local, no data leak.
Build a renovate.json file to automate dependency updates. Choose schedule, automerge, and package rules. Local.
Get a random, unique superpower with a detailed description and limit. Perfect for character creation or daydreaming.
Enter a date and location (or use GPS) to see exact golden hour and blue hour times for perfect natural light.