Outline and border look similar but behave differently in layout, and the distinction matters both for design quality and accessibility compliance.
Loading Border Builder…
Preview outline alongside border on the same element
Adjustable outline-offset for gap between element and outline ring
Accessibility notes on focus-visible outline requirements
Generates outline shorthand and outline-offset declarations
Drop the Border Builder into any page — blog post, product docs, intranet, school portal — with a single line of HTML. Your visitors get the full tool, processed entirely in their browser. No backend, no uploads, no signup.
Embed code
<iframe
src="https://www.fixtools.io/css-tool/border-builder?embed=1"
width="100%"
height="780"
frameborder="0"
style="border:0;border-radius:16px;max-width:900px;"
title="Border Builder by FixTools"
loading="lazy"
allow="clipboard-write"
></iframe>Attribution-friendly: a small "Powered by FixTools" link appears in the embed footer.
The most important difference between outline and border is that outline does not participate in the document layout. An outline can extend beyond the element's border box into the surrounding space without pushing other elements. Adding a 2px outline to an element does not increase its measured width or height and does not shift adjacent content. This makes outline ideal for focus indicators, selection highlights, and temporary visual annotations where you want to mark an element visually without disturbing the layout. Border, by contrast, is part of the box model and affects layout calculations.
Outline-offset is a separate property that specifies the distance between the outline and the element's border edge. A positive value pushes the outline outward; a negative value pulls it inward, potentially overlapping the element's content. Setting outline: 2px solid #6366f1 with outline-offset: 3px creates a ring that floats 3px outside the element border, which improves visual clarity on elements with their own border. Outline-offset accepts negative values too: outline-offset: -4px places the outline inside the element, creating an inner highlight effect commonly used in image galleries and content pickers.
Removing outline on focused elements with outline: none or outline: 0 is one of the most common accessibility violations on the web. Keyboard users who navigate with Tab rely on the focus indicator to know which element is active. WCAG 2.1 Success Criterion 2.4.7 requires a visible focus indicator. The recommended pattern is to keep the native focus indicator or replace it with a custom one using :focus-visible rather than :focus. The :focus-visible pseudo-class applies styles only when the browser determines keyboard navigation is in use, allowing mouse clicks to suppress the ring while still serving keyboard users correctly.
Performance is the other practical reason to prefer outline over border for any visual ring that toggles often. Outline changes do not trigger layout, so toggling outline on a hover or focus event produces a paint-only update. Border changes that include width or style force a layout recalculation because the box model changes. On a single isolated element the difference is invisible, but in long lists where many items respond to keyboard navigation, in drag-and-drop interfaces where dragover fires repeatedly during a drag, or in animated transitions that swap the ring shape on state change, the cumulative cost of border-driven reflows shows up as jank. Pair outline with outline-offset to control the visual gap and with box-shadow as a fallback for older browsers that did not respect border-radius on outline. The result is a focus indicator that is both accessible and inexpensive enough to use freely.
Set outline-width to 2px and outline-style to solid, then use the offset slider to add a 2px gap between the element and the outline ring. This is the recommended starting point for accessible focus indicators that meet WCAG 2.1 contrast and size requirements.
Step-by-step guide to css outline generator:
Set outline style and width
Choose outline-style (solid is most common for focus rings) and set outline-width to 2px or 3px. Thinner outlines may not meet WCAG minimum size requirements for focus indicators.
Choose outline color
Select a color with sufficient contrast against both the element background and the surrounding page background. WCAG 2.1 SC 1.4.3 applies to focus indicators in WCAG 2.2.
Adjust outline-offset
Add 2px to 4px of offset to separate the outline from the element edge. On elements with their own border, offset prevents the outline from sitting against the border and looking ambiguous.
Copy the CSS
Copy the outline and outline-offset declarations. Apply them inside a :focus-visible selector rather than :focus to avoid showing the ring on mouse interactions.
Common situations where this approach makes a real difference:
Accessible focus indicator for buttons
A button needs a visible focus ring for keyboard navigation. The recommended pattern is: .btn:focus-visible { outline: 3px solid #6366f1; outline-offset: 2px; }. The 3px width meets WCAG 2.2 focus appearance requirements. The offset separates the ring from the button border. Using :focus-visible suppresses the ring for mouse clicks while serving keyboard and switch access users.
Custom focus ring that follows border-radius
A rounded button needs a rounded focus ring. Modern browsers follow border-radius on outline since 2021-2022, but for broader support: .btn:focus-visible { outline: 2px solid transparent; box-shadow: 0 0 0 3px #6366f1; }. The transparent outline satisfies outline-requirement checks in automated accessibility tools while box-shadow provides the visible rounded ring that follows the button's border-radius.
Image picker with inner selection outline
In an image grid, selected images need a selection indicator without adding space outside the grid item. Setting outline: 3px solid #6366f1 with outline-offset: -3px places the ring inside the image boundary. The negative offset pulls the outline inward by 3px, sitting just inside the image edges. This marks the selection without affecting grid spacing or image dimensions.
Removing native outline and replacing with custom style
To replace the browser's native focus ring with a branded one: .interactive:focus { outline: none; } .interactive:focus-visible { outline: 2px solid #6366f1; outline-offset: 3px; }. The :focus rule removes the native ring universally. The :focus-visible rule adds the custom ring back only for keyboard navigation. Never use the :focus rule alone without a :focus-visible replacement, as that leaves keyboard users with no visible indicator.
Get better results with these expert suggestions:
Use box-shadow to simulate outline for rounded focus rings in older browsers
Browsers that do not follow border-radius on outline produce rectangular focus rings on rounded elements. A box-shadow: 0 0 0 3px #6366f1 simulates an outline that follows border-radius in all browsers. Use both together: outline for browser-native focus and box-shadow as the visible styled ring, with outline: 2px solid transparent to satisfy browsers that require an explicit outline for focus.
Negative outline-offset creates inner rings
Setting outline-offset: -4px places the outline inside the element's border edge. This creates an inner highlight ring rather than an outer glow. The effect is used in image selection interfaces where the border belongs to the image container and the inner ring indicates the selection state without adding space outside the container.
Use :focus-visible instead of :focus for custom focus styles
:focus applies styles whenever an element is focused by any input method, including mouse clicks. :focus-visible applies styles only when the browser determines keyboard navigation triggered the focus, suppressing the ring on mouse interactions. This gives keyboard users a clear indicator while keeping the interface clean for mouse users.
Outline-color: auto uses the browser's system focus color
Setting outline: 2px auto on :focus or :focus-visible tells the browser to use its native system focus color, which on macOS is a blue ring and on Windows is a black dotted ring. This automatically adapts to high-contrast accessibility modes and OS-level focus color customizations without you needing to specify a color.
Never remove outline without a replacement
Setting outline: none on :focus removes the visible focus indicator for keyboard users without providing any alternative. Replace it with a custom focus style: use :focus-visible and set a distinct outline color, width, and offset that meets WCAG 2.1 color contrast requirements for focus indicators.
Use outline-offset to separate the ring from the border
On bordered elements, a zero-offset outline sits directly against the border and can look cluttered. Adding outline-offset: 2px to 4px creates visible separation between the element's own border and the focus ring, making both clearer and more distinct.
Outline does not clip to border-radius by default in older browsers
Modern browsers (Chrome 94+, Firefox 88+, Safari 16+) respect border-radius on outlines. Older browsers render outlines as rectangles regardless of the element's border-radius. If you support older browsers, test your outline focus styles and consider using box-shadow as a fallback for rounded focus rings.
More use-case guides for the same tool:
Other tools you might find useful:
Open the full Border Builder — free, no account needed, works on any device.
Open Border Builder →Free · No account needed · Works on any device