Sub topic 3
Target Size and Spacing
Assume you know basic HTML, CSS selectors, the box model, pseudo-classes, and browser developer tools. This chapter focuses on applying those skills consistently to clickable controls.
Make targets easy to hit
A clickable target includes its padding, not only its text or icon. Give buttons and important links enough area for a finger or pointer. A practical baseline is a minimum height of 44px. Add space between neighboring targets so one tap does not activate the wrong control.
<style>
.btn {
min-height: 44px;
padding: 0 1rem;
border: 2px solid #1d4ed8;
border-radius: 8px;
background: #1d4ed8;
color: white;
font: inherit;
font-weight: 600;
}
.actions {
display: flex;
gap: 0.75rem;
flex-wrap: wrap;
}
.btn--secondary {
background: white;
color: #1d4ed8;
}
.btn:focus-visible {
outline: 3px solid #f59e0b;
outline-offset: 3px;
}
.btn[aria-busy="true"] {
opacity: 0.7;
cursor: wait;
}
</style>
<div class="actions">
<button class="btn" type="button">Save changes</button>
<button class="btn btn--secondary" type="button">Cancel</button>
</div>Rank controls by importance
Use one primary action per region, such as Save changes. Use a secondary style for a safe alternative, such as Cancel. Use tertiary actions as plain links or low-emphasis buttons for less important choices.
| Level | Visual treatment | Typical use |
|---|---|---|
| Primary | Filled, high contrast | Complete the main task |
| Secondary | Outlined or lightly filled | Alternative or safe exit |
| Tertiary | Text or inline link | Optional, low-risk action |
Label the result
Labels should state what happens next. Prefer Download report over Continue, and Delete account over Submit. Avoid labels that describe only the control, such as Button.
Handle disabled and loading states
A disabled control cannot be used now. Use the native disabled attribute when it should also leave the keyboard order. Use aria-disabled="true" when it must remain focusable, and block the action in JavaScript. During loading, preserve the target size, show progress, and prevent duplicate submission.
Keep and test a consistent pattern
Reuse the same height, padding, radius, focus outline, and state behavior across the site. Test with a keyboard, a narrow touch screen, and a contrast checker. Tab through every control, activate it with Enter or Space, inspect its target dimensions, and confirm that color is not the only cue.
Exercise
A small text-only “Save” control sits beside “Delete,” and users often tap the wrong one. What should you change first?
Show answer
Give both controls a minimum target size, add spacing between them, and make “Delete” visually distinct while keeping “Save” as the primary action.