The CSS User Interface module includes properties that control how elements visually respond to the user. In this topic, we focus on two useful UI properties: outline-offset and resize. They help improve focus styling and let users resize elements such as textareas.
These properties are especially important for accessibility and usability: they make it easier for users to see which element is selected and to adjust areas where they type or view content.
outline-offset controls the space between an element’s border and its outline.resize allows users to resize elements (commonly <textarea>).resize with overflow gives you more control over scrollable areas.The outline-offset property moves the outline away from (or closer to) the edge of an element. Outlines are drawn outside the border, and outline-offset defines the gap between the outline and the border.
Positive values push the outline outward, creating a nice “halo” effect around focused elements. Negative values pull the outline closer or even inside the border edge.
/* outline-offset syntax and example */
/* Syntax */
outline-offset: <length> | initial | inherit;
/* Example */
.my-element {
outline: 2px solid #ff6f61;
outline-offset: 5px;
}
Below, both boxes have an outline. The only difference is the outline-offset value.
Try changing the offset value to see how far the outline moves relative to the border.
The resize property allows a user to resize an element (usually a <textarea> or <div>) by dragging its corner or edge. It controls which directions resizing is allowed.
This is helpful for giving users more space to type or view content, while still keeping the layout under control.
/* resize property syntax and example */
/* Syntax */
resize: none | both | horizontal | vertical | block | inline | initial | inherit;
/* Example */
textarea {
resize: both;
}
resize: both (default browser behavior)
resize: none (resizing disabled)
Try dragging the bottom-right corner of each textarea. The first one can be resized freely, while the second one is locked.
outline and outline-offset for better keyboard navigation.resize: both.resize: none so the page design stays intact.outline-offset with a small positive value (like 2px–6px) to make focus outlines easier to see without crowding the element.outline-offset values can be useful for tighter designs, but check that the outline is still clearly visible.resize mainly on elements that contain text or scrollable content (like textareas).resize with overflow: auto; so scrollbars appear when content exceeds the element size.resize: none when resizing could break your layout or overlap other elements.outline-offset of 8px. Test how it looks when the button is focused.<textarea> that can only be resized horizontally using resize: horizontal;.outline-offset (for example, -4px) to a box and observe how the outline moves closer to or inside the border.resize with max-width and max-height so users can resize elements, but only up to a certain limit.