# Contact Form

> A tidy contact form with name and email side by side on wide screens, a message box and a send button.

- Category: [CSS Form Elements](https://copy-css.com/category/forms)
- Tags: contact, form, message, textarea, responsive, grid
- Live preview: https://copy-css.com/snippets/contact-form
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<form class="contact-form">
  <label>Name<input type="text" name="name" autocomplete="name" required></label>
  <label>Email<input type="email" name="email" autocomplete="email" required></label>
  <label class="contact-form-wide">Message<textarea name="message" rows="3" required></textarea></label>
  <button type="submit">Send message</button>
</form>
```

## CSS

```css
.contact-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 340px;
  padding: 16px;
  box-sizing: border-box;
  border-radius: 16px;
  background: #fff;
  font-family: system-ui, sans-serif;
}

.contact-form label {
  display: grid;
  gap: 4px;
  color: #334155;
  font-size: 12px;
  font-weight: 600;
}

.contact-form-wide,
.contact-form button {
  grid-column: 1 / -1;
}

.contact-form input,
.contact-form textarea {
  box-sizing: border-box;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #0f172a;
  font: 14px system-ui, sans-serif;
  resize: vertical;
}

.contact-form input:focus-visible,
.contact-form textarea:focus-visible {
  border-color: #0f172a;
  outline: 2px solid #0f172a;
  outline-offset: -1px;
  background: #fff;
}

.contact-form button {
  padding: 10px;
  border: 0;
  border-radius: 8px;
  background: #0f172a;
  color: #fff;
  font: 600 14px system-ui, sans-serif;
  cursor: pointer;
}

.contact-form button:hover {
  background: #334155;
}

.contact-form button:focus-visible {
  outline: 2px solid #0f172a;
  outline-offset: 2px;
}
```

## Notes

- This CSS Contact Form is 65 lines of pure CSS (1.2 KB) with no JavaScript and no dependencies. It uses CSS Grid and keyboard focus styles.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
