Sub topic 11
Hover, focus, active, disabled and error states
This chapter assumes you can open DevTools, read a CSS rule, and find the matching state in a design file. A static screenshot of a page shows only one state of each control. A visual QA pass must also check the states a control passes through while someone uses it.
The states to check
Designs usually define these states for buttons, links, inputs and similar controls.
| State | When it applies | Common defect |
|---|---|---|
| Default | Nothing is happening | Wrong color or border |
| Hover | Pointer is over the control | Missing, or only works on one element |
| Focus | Keyboard or click has selected it | Outline removed, or low visibility |
| Active | Pointer or key is held down | No pressed feedback |
| Disabled | Control cannot be used | Looks clickable, or text is unreadable |
| Error | Input failed validation | Red border but no message, or color alone |
Ask the designer for a state sheet if the file only shows the default state. Do not guess the missing states.
Forcing states in DevTools
You cannot hold a hover and inspect at the same time. DevTools solves this. In the Elements panel, select the element, open the :hov toggle in the Styles pane, and tick :hover, :focus, :active or :focus-visible. The styles then apply until you untick them. Compare the computed values with the design as you did for the default state.
For disabled and error states, edit the markup instead. Add the disabled attribute to a button, or aria-invalid="true" to an input. If the real page shows these states only after an action, such as a failed form submit, reproduce that action as well. Forced styles can hide a bug where the real trigger never fires.
/* Typical state rules you will be checking against the design */
.button:hover { background: #0b5cd5; }
.button:focus-visible { outline: 3px solid #1a1a1a; outline-offset: 2px; }
.button:active { transform: translateY(1px); }
.button:disabled { background: #d0d4da; color: #5b6168; cursor: not-allowed; }
.field[aria-invalid="true"] { border-color: #b3261e; }Transitions and keyboard use
Check how a state changes, not only the end result. Hover a control and watch for a jump, a flicker, or a transition that is much slower or faster than the design notes say. Then use the Tab key through the whole page. Every interactive element should show a focus indicator, in a logical order, and it should not be clipped by a parent with overflow: hidden.
Error states
An error state has several parts: the field styling, the message text, its position, and its color. Submit an empty form and check each part. The message should sit where the design puts it and should not shift other content unexpectedly. Also confirm the error is not shown by color alone, since some users cannot tell red from other colors. An icon or text should accompany it.
Exercise
A button looks correct in the default state. In DevTools you tick :focus-visible and see no change. What do you check next, and why does it matter?
Show answer
Look in the Styles pane for a rule such as outline: none or outline: 0 that removes the browser's default focus indicator, and check whether the design supplies a replacement. Without any visible focus indicator, keyboard users cannot tell which control is selected, so this is a defect to report even though the default state matches.
Exercise
Why is it not enough to force :hover in DevTools and confirm the color matches?
Show answer
Forcing the state only shows the CSS rule. It does not confirm that a real pointer triggers it on the right element, or that the transition timing feels right. Hover the control with a real pointer as well.