Button text must always be readable. A developer must check button text in its default, hover, and disabled states. Missing CSS variables or low contrast can make text invisible.
By Pawan Nayar · from the LLOS AI Learning record
Button text must always be readable.
A developer must check button text in its default, hover, and disabled states. Missing CSS variables or low contrast can make text invisible.
Users often report that button text is invisible or hard to read. This problem happens many times. A common cause is an undefined CSS variable. For example, a button might use `background: var(--accent)`, but `--accent` is never defined. The background then becomes transparent. White text on a light page background becomes invisible. Another cause is low contrast in the disabled state. A disabled button might have `opacity: 0.3` or a light text color on a light background. This makes the text unreadable. A hover state bug can also cause issues. For example, a button might have `color: white; background: white` when the user points at it. This makes the text disappear.
A developer updates a website's design. The developer changes some CSS variables. A button uses `var(--primary-color)` for its text. The developer forgets to define `--primary-color` in the main stylesheet. When a user visits the page, the button text is invisible. The user cannot click the button because they cannot see its label.
Resolved from this lesson's own record — real definitions, not invented for this page.
More from the same record, pulled by shared topic — not written new for this page.
A developer uses a main container for the entire experience. Inside, specific sections handle different parts.
A button should only be as wide as its text and the space around the text. This is called content-sized.
A developer should use inline SVG for icons that need to be centered. Inline SVG allows precise control over the icon's position.
A developer uses `#interactive-svg-demo` for the main section that holds an SVG image. JavaScript code will interact with this section.
Button text must always be readable. A developer must check button text in its default, hover, and disabled states. Missing CSS variables or low contrast can make text invisible.