Guide
Designing an accessible call-to-action button and its CSS
A call-to-action button is often the most important element on a page, and it is also where small design choices cause the most trouble: text that is hard to read, a hover state that is invisible or a button that cannot be reached by keyboard. This generator lets you set the look, checks the contrast against the Web Content Accessibility Guidelines and gives you clean HTML and CSS.
Settings
Choose the button text and link, a CSS class name, the background, text and hover colours with colour pickers, and sliders for corner radius, font size, vertical and horizontal padding, font weight and border width. Toggle a drop shadow, and choose whether the link opens in a new tab, which adds target="_blank" and rel="noopener noreferrer". Presets for blue, green, orange, dark and a pill shape give quick starting points.
The contrast check
WCAG 2 measures contrast as a ratio between the relative luminance of two colours, from 1 to 1 for identical colours to 21 to 1 for black on white. Level AA requires 4.5 to 1 for normal text and 3 to 1 for large text, which means at least 24 pixels, or 18.66 pixels in bold. Level AAA asks for 7 to 1 for normal text. The tool applies the right threshold for the font size and weight you have set and reports pass or fail in words.
The preview and hover
The preview draws your button with its real colours, and hovering over it shows the hover colour and a slight lift. That is how the generated CSS will behave. Keep an eye on both states: the text should stay readable when the background changes, and the change should be visible without relying on colour alone, which is why the CSS also moves the button slightly.
The code
The HTML is a single link with your class name. The CSS sets the display, padding, colours, font, border, radius, text decoration and cursor, the shadow if you chose one and a short transition. It adds a hover rule, a :focus-visible rule with a visible outline for keyboard users, and a prefers-reduced-motion rule that switches the transition and the lift off. Copy both and put the CSS in your stylesheet.
Worked examples
The default button, white text on #2563eb, has a contrast ratio of 5.17 to 1, and the tool says it passes. The size is 18 px and weight 700, which counts as large text, so the lower 3 to 1 threshold applies, and it also reaches 4.5 to 1. The orange preset uses white on #f59e0b; the ratio is just over 2 to 1, the tool says it does not pass and a stronger notice appears because the ratio is below 3 to 1. The generated HTML for the default is <a class="cta-button" href="https://example.com/signup">Start your free trial</a>.
Limits
Contrast is measured for the two colours you chose, not for the page behind the button, and text on images or gradients needs its own check. The CSS uses system fonts unless you change it. The tool does not test the button in context, nor does it make a page accessible by itself: focus order, labels and the wording of the button also matter. Test with a keyboard before publishing.
Related tools
- Contrast Checker tests any pair of colours against WCAG levels.
- CSS Gradient Generator makes gradient backgrounds for buttons and sections.
- Before & After Slider Generator is another snippet generator for web pages.
- Mailto Link Generator builds an email button.
Checked against the current version of the CTA Button Generator on .

