Дефолтные стили форм в браузере выглядят по-разному в каждой ОС. Разбираем как создать современные, единообразные стили для input, кнопок, select, чекбоксов и таблиц.

- Стилизация input — текстовое поле
- Набор кнопок — primary, outline, ghost, danger
- Стилизация select — выпадающий список
- Полная форма обратной связи
- Кастомный чекбокс через CSS
- Стилизация таблиц
- Часто задаваемые вопросы о стилизации форм
- Как изменить цвет placeholder в input?
- Как убрать стандартную стрелку у select?
- Как стилизовать checkbox через CSS?
Стилизация input — текстовое поле
/* Сброс дефолтных стилей браузера */
input, textarea, select {
appearance: none;
-webkit-appearance: none;
box-sizing: border-box;
}
/* Современный input */
.input {
display: block;
width: 100%;
padding: 10px 14px;
font-size: 1rem;
font-family: inherit; /* наследует шрифт от body */
color: #111827;
background: #ffffff;
border: 1px solid #d1d5db;
border-radius: 8px;
outline: none;
transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.input::placeholder {
color: #9ca3af;
}
.input:hover {
border-color: #9ca3af;
}
.input:focus {
border-color: #2563eb;
box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.input:disabled {
background: #f3f4f6;
color: #9ca3af;
cursor: not-allowed;
}
.input.error {
border-color: #dc2626;
box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}
.input.success {
border-color: #16a34a;
}
/* Input с иконкой */
.input-wrapper {
position: relative;
}
.input-icon {
position: absolute;
left: 12px;
top: 50%;
transform: translateY(-50%);
color: #6b7280;
pointer-events: none;
}
.input-with-icon {
padding-left: 40px;
}
/* Размеры */
.input-sm { padding: 6px 10px; font-size: 0.875rem; }
.input-lg { padding: 14px 18px; font-size: 1.125rem; }

Набор кнопок — primary, outline, ghost, danger
/* Базовый сброс кнопки */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 8px;
padding: 10px 20px;
font-size: 0.9rem;
font-weight: 600;
font-family: inherit;
line-height: 1;
border: 2px solid transparent;
border-radius: 8px;
cursor: pointer;
text-decoration: none;
transition:
background-color 0.2s ease,
border-color 0.2s ease,
color 0.2s ease,
transform 0.1s ease,
box-shadow 0.2s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled {
opacity: 0.5;
cursor: not-allowed;
pointer-events: none;
}
/* Primary — основная кнопка */
.btn-primary {
background: #2563eb;
color: white;
border-color: #2563eb;
}
.btn-primary:hover {
background: #1d4ed8;
border-color: #1d4ed8;
box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}
/* Outline — рамка */
.btn-outline {
background: transparent;
color: #2563eb;
border-color: #2563eb;
}
.btn-outline:hover {
background: #2563eb;
color: white;
}
/* Ghost — прозрачный */
.btn-ghost {
background: transparent;
color: #374151;
border-color: transparent;
}
.btn-ghost:hover {
background: #f3f4f6;
border-color: #f3f4f6;
}
/* Danger — деструктивное действие */
.btn-danger {
background: #dc2626;
color: white;
border-color: #dc2626;
}
.btn-danger:hover {
background: #b91c1c;
border-color: #b91c1c;
box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
}
/* Success */
.btn-success {
background: #16a34a;
color: white;
border-color: #16a34a;
}
.btn-success:hover { background: #15803d; border-color: #15803d; }
/* Размеры */
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-full { width: 100%; }
/* Loading state */
.btn.loading {
position: relative;
color: transparent;
pointer-events: none;
}
.btn.loading::after {
content: "";
position: absolute;
width: 18px; height: 18px;
border: 2px solid rgba(255,255,255,0.3);
border-top-color: white;
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

Стилизация select — выпадающий список
.select {
appearance: none;
-webkit-appearance: none;
display: block;
width: 100%;
padding: 10px 40px 10px 14px;
font-size: 1rem;
font-family: inherit;
color: #111827;
background:
#ffffff
url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' fill='none' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
no-repeat right 14px center;
border: 1px solid #d1d5db;
border-radius: 8px;
cursor: pointer;
outline: none;
transition: border-color 0.2s, box-shadow 0.2s;
}
.select:hover { border-color: #9ca3af; }
.select:focus {
border-color: #2563eb;
box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.select:disabled {
background-color: #f3f4f6;
color: #9ca3af;
cursor: not-allowed;
}

Полная форма обратной связи
<!-- HTML -->
<form class="contact-form">
<div class="field">
<label class="label" for="name">Имя <span class="required">*</span></label>
<input class="input" id="name" type="text" placeholder="Ваше имя" required>
</div>
<div class="field">
<label class="label" for="email">Email <span class="required">*</span></label>
<input class="input" id="email" type="email" placeholder="mail@example.com" required>
</div>
<div class="field">
<label class="label" for="topic">Тема</label>
<select class="select" id="topic">
<option value="">Выберите тему</option>
<option value="question">Вопрос</option>
<option value="bug">Сообщить об ошибке</option>
<option value="other">Другое</option>
</select>
</div>
<div class="field">
<label class="label" for="message">Сообщение</label>
<textarea class="input" id="message" rows="5" placeholder="Ваше сообщение..."></textarea>
</div>
<button type="submit" class="btn btn-primary btn-full">Отправить</button>
</form>
/* CSS формы */
.contact-form {
max-width: 520px;
padding: 32px;
background: white;
border: 1px solid #e5e7eb;
border-radius: 16px;
box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}
.field {
margin-bottom: 20px;
}
.label {
display: block;
margin-bottom: 6px;
font-size: 0.875rem;
font-weight: 500;
color: #374151;
}
.required {
color: #dc2626;
}
textarea.input {
resize: vertical;
min-height: 120px;
}
/* Подпись об ошибке */
.field-error {
margin-top: 4px;
font-size: 0.8rem;
color: #dc2626;
}

Кастомный чекбокс через CSS
/* HTML: <label class="checkbox-label"><input type="checkbox"><span>Согласен</span></label> */
.checkbox-label {
display: flex;
align-items: center;
gap: 10px;
cursor: pointer;
user-select: none;
}
.checkbox-label input[type="checkbox"] {
appearance: none;
-webkit-appearance: none;
width: 18px;
height: 18px;
border: 2px solid #d1d5db;
border-radius: 4px;
background: white;
cursor: pointer;
transition: background 0.15s, border-color 0.15s;
flex-shrink: 0;
position: relative;
}
.checkbox-label input[type="checkbox"]:checked {
background: #2563eb;
border-color: #2563eb;
}
.checkbox-label input[type="checkbox"]:checked::after {
content: "✓";
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 12px;
font-weight: 700;
}
.checkbox-label input[type="checkbox"]:focus-visible {
outline: 2px solid #2563eb;
outline-offset: 2px;
}

Стилизация таблиц
/* Обёртка для горизонтальной прокрутки на мобильных */
.table-wrapper {
overflow-x: auto;
-webkit-overflow-scrolling: touch;
border-radius: 12px;
border: 1px solid #e5e7eb;
}
/* Сама таблица */
.table {
width: 100%;
border-collapse: collapse;
font-size: 0.9rem;
background: white;
}
/* Шапка */
.table thead {
background: #f9fafb;
}
.table th {
padding: 12px 16px;
text-align: left;
font-weight: 600;
font-size: 0.75rem;
color: #6b7280;
text-transform: uppercase;
letter-spacing: 0.05em;
border-bottom: 1px solid #e5e7eb;
white-space: nowrap;
}
/* Ячейки */
.table td {
padding: 14px 16px;
color: #374151;
border-bottom: 1px solid #f3f4f6;
vertical-align: middle;
}
/* Последняя строка без разделителя */
.table tbody tr:last-child td {
border-bottom: none;
}
/* Hover строки */
.table tbody tr:hover td {
background: #f0f9ff;
}
/* Полосатая таблица */
.table-striped tbody tr:nth-child(even) td {
background: #f9fafb;
}
/* Липкий заголовок */
.table-sticky th {
position: sticky;
top: 0;
background: #f9fafb;
z-index: 1;
}
/* Выравнивание числовых колонок */
.table td.numeric,
.table th.numeric {
text-align: right;
font-variant-numeric: tabular-nums;
}

Часто задаваемые вопросы о стилизации форм
Как изменить цвет placeholder в input?
Используй псевдоэлемент ::placeholder: input::placeholder { color: #9ca3af; }. Поддерживаются свойства color, opacity, font-style, font-size. Чтобы placeholder изменялся при фокусе: input:focus::placeholder { color: #d1d5db; } — станет светлее когда пользователь начал вводить.
Как убрать стандартную стрелку у select?
Добавь appearance: none; -webkit-appearance: none; на элемент select — дефолтная стрелка исчезнет. Потом добавь свою через свойство background с инлайновым SVG или через псевдоэлемент ::after на обёртке (сам select не поддерживает ::after).
Как стилизовать checkbox через CSS?
Стандартный <input type="checkbox"> плохо поддаётся стилизации. Самый надёжный подход: скрой стандартный чекбокс через appearance: none, затем стилизуй его как обычный блочный элемент — добавь нужные размеры, рамку, скругление, и используй ::after для галочки при :checked состоянии. Подробный пример есть в этой статье выше.



