HTML and CSS guide
Put a mailto link on a button
A mailto control goes to an email destination, so it should remain a link. CSS can give that link the size, contrast, and states of a button.
Correct element
Style a link instead of changing its meaning
Use <a href="mailto:…">. A link already supports keyboard focus, browser status text, context menus, and assistive-technology link lists. A<button> is for an action inside the current page.
This is a real anchor with button styling.
Tested example
Add the URL, label, and visible states
This example keeps a 44-pixel minimum target, clear contrast, a hover state, and a visible keyboard focus ring. The subject and body are percent-encoded inside the href.
<a class="email-button" href="mailto:sales@example.com?subject=Pricing%20question&body=Hi%2C%0A%0AI%20would%20like%20to%20ask%20about%20pricing.">
Ask about pricing
</a>.email-button {
display: inline-flex;
min-height: 44px;
align-items: center;
padding: 12px 20px;
background: #a12f24;
color: #fff;
font-weight: 600;
text-decoration: none;
}
.email-button:hover { background: #7d251b; }
.email-button:focus-visible {
outline: 2px solid #a12f24;
outline-offset: 3px;
}Accessible copy
Name the result, not the control type
Use a label such as Email support, Ask about pricing, or Send product feedback. Avoid labels such as Click here or Submit. The visitor should know that the control opens an email composer.
Good labels
- Email support
- Ask about pricing
- Send feedback
Avoid
- Click here
- Submit
- Continue
Common mistake
Do not hide a link behind JavaScript
Avoid onclick="window.location='mailto:…'" on a button. It adds code without improving the handoff. It also removes the destination from the HTML and can make the control harder to inspect or reuse.
Do not put an anchor inside a button or a button inside an anchor. Nested interactive controls create invalid behavior for keyboard and screen-reader users.
Before publishing
Check the complete interaction
- 01Tab to the link and confirm the focus ring is visible.
- 02Open it and confirm the correct recipient, subject, and body appear.
- 03Check the label at narrow widths and with larger text.
- 04Keep another contact route when email delivery must be guaranteed.
Live output preview
Ready to build
Generate the button href before you style it
The free smart-mailto generator builds the encoded href and ready-to-paste anchor. Add your own class and button styles after copying it.
Open the mailto generator