hyphens CSS Tester - Online Auto, Manual, None
Set hyphens: auto with lang attribute and see automatic hyphenation. Perfect for justified text. Browser built‑in.
UD5 Toolkit
Experience a textarea that grows with your content. No more scrollbars — just seamless expansion. Compare with a standard fixed textarea in real time.
function autoResizeTextarea(textarea) {
textarea.style.height = 'auto';
textarea.style.height = textarea.scrollHeight + 'px';
}
// Attach to your textarea
const ta = document.getElementById('myTextarea');
ta.addEventListener('input', () => autoResizeTextarea(ta));
// Also trigger on window resize
window.addEventListener('resize', () => autoResizeTextarea(ta));
// With max-height support
function autoResizeWithMax(textarea, maxHeight) {
textarea.style.height = 'auto';
const newHeight = Math.min(textarea.scrollHeight, maxHeight);
textarea.style.height = newHeight + 'px';
textarea.style.overflowY = textarea.scrollHeight > maxHeight ? 'auto' : 'hidden';
}
Also check out the modern CSS approach: field-sizing: content; (Chrome 123+)
scrollHeight property, which returns the full height of an element's content (including overflow). The process is: ① Reset height to auto (allows the browser to calculate the natural height), ② Read scrollHeight to get the actual content height, ③ Set the element's height to that value. This is triggered on input events. For max-height support, simply clamp the value and toggle overflow-y between hidden and auto.
field-sizing: content; enables native auto-resize behavior for textareas. Simply apply textarea { field-sizing: content; } in your stylesheet. However, browser support is limited — it works in Chrome 123+ and Edge 123+, but Firefox and Safari do not yet support it (as of 2025). For production use with broad compatibility, the JavaScript scrollHeight method remains the recommended approach. You can use @supports (field-sizing: content) for progressive enhancement.
newHeight = Math.min(scrollHeight, maxHeight). When the content exceeds maxHeight, switch overflow-y to auto so a native scrollbar appears. This gives users the best of both worlds — automatic growth for reasonable amounts of text, with a safety net for extremely long content. Try adjusting the Max Height slider in the configuration panel above to see this in action.
scrollHeight method works consistently across iOS Safari, Android Chrome, and all modern mobile browsers. One tip: listen for orientationchange and resize events to recalculate height when the viewport changes (e.g., when the virtual keyboard appears). Also consider using debounce on resize events for smoother performance.
ref and attach the onInput handler. You can create a custom hook like useAutoResize(ref, maxHeight) for reusability.@input with a template ref ($refs) or create a custom directive v-auto-resize.@HostListener('input') or (input) event binding with ElementRef.autosize (npm) which handles edge cases, or wrap the native scrollHeight logic in a framework-idiomatic way. The core principle remains the same across all frameworks.
scrollHeight read and height write are fast DOM operations. However, if you're also performing heavy operations on each keystroke (like real-time Markdown preview, auto-save to server, or complex validation), consider debouncing those additional operations while keeping the resize itself synchronous for smooth visual feedback. Avoid forcing layout thrashing — the standard pattern (reset height → read scrollHeight → set height) is already optimized to minimize reflows.
Set hyphens: auto with lang attribute and see automatic hyphenation. Perfect for justified text. Browser built‑in.
Create a customizable checkerboard or grid background using pure CSS gradients. Adjust cell size and colors. Copy the code.
Design a square foot garden by dragging vegetables into a grid. See companion planting warnings and spacing tips. Print plan.
Answer where you're sealing (shower, window, baseboard) to get the right type of caulk (100% silicone, acrylic latex, etc.). Avoid moldy seals.
Configure how your PWA launches: focus existing or create new. Test with the launch_handler manifest field.
Toggle image‑rendering: auto, pixelated, crisp‑edges on a scaled image. Essential for pixel art display.
Press Ctrl+V to paste an image from your clipboard into the page. See dimensions and download. Simple utility.
Watch a simulation of how the JavaScript event loop handles synchronous code, microtasks, and macrotasks. Learn async.
Create promises that resolve or reject after a delay. See state changes and chain .then/.catch. Debug async code.
Write a generator function and step through it with next(). See values and done state. Understand iterators.
Apply a Proxy to an object and see the get/set traps log fired in real time. Understand metaprogramming. Local.
Calculate large Fibonacci numbers in a Web Worker. See the UI remain responsive. Copy the pattern for your app.
See how grid-auto-flow: row vs column changes item placement. Add and remove items to understand the algorithm. Visual.
Demonstrate how to add custom headers and POST‑like functionality to EventSource using a polyfill. Code and example.
Test the experimental Translation API to translate text between languages directly in the browser, without cloud calls. Check support and copy the JavaScript starter.
Add grid items beyond defined tracks and see how implicit rows/columns expand. Set sizes interactively. Master the grid.
Resize the container and see the difference between repeat(auto‑fill, …) and auto‑fit. Understand responsive grid behavior.
Toggle scrollbar‑gutter: stable to reserve space for the scrollbar and avoid content jumps. Visual demo with two columns.
Test overscroll‑behavior: contain to prevent background scroll or pull‑to‑refresh. See the effect in a live demo.
Acquire and release locks across tabs. Prevent race conditions in IndexedDB or localStorage. Visual queue and lock state.
Register a periodic background sync to fetch fresh data even when the tab is closed. Understand the API and limits.
Test the Fullscreen API: request fullscreen on a colored div, detect changes, and copy the JavaScript boilerplate.
See the View Transitions API in action. Cross‑fade and morph between two states. Copy the JavaScript starter code.
Press any key to see the complete KeyboardEvent properties: key, code, keyCode, modifiers. Indispensable for game & shortcut developers.
Write JavaScript code and see the output or console.log results immediately. Safe iframe sandbox. For quick experiments.
Scroll down to see images load lazily. Code snippet provided. Learn how native loading='lazy' works.
Paste any JavaScript snippet and get a ready‑to‑drag bookmarklet link. Minify and encode automatically. Pure client.
Convert any text into JavaScript‑style \uXXXX escape sequences and vice versa. Handles emojis. Useful for i18n development.
Paste any JavaScript expression and see its evaluated type and value. Understand JS coercion and type quirks. Educational.
Find safe mixing ratios for the classic elephant toothpaste demonstration. Volume adjustments for different container sizes.