Перейти к основному содержимому
← 📄 HTML & the platform·Модуль A5 · Урок 8
ЗаданиеStyle the icon button to have a 44×44 hit area. Use width:44px, height:44px, and display:grid + place-items:center.

Размер сенсорной цели: минимум 44 пикселя.

75 XP6 min
Теория

44px is the safe target size (the guidelines differ)

The numbers are not identical everywhere: Apple's HIG recommends 44 × 44 pt, Material Design recommends 48 × 48 dp, WCAG 2.5.5 (Target Size, Enhanced — level AAA) asks for 44 × 44 CSS px, and the newer WCAG 2.2 AA criterion 2.5.8 (Target Size, Minimum) only requires 24 × 24 CSS px (with spacing exceptions). Aim for 44 × 44 CSS pixels and you satisfy the strictest of the WCAG ones. Smaller targets are physically hard to hit for users with limited fine motor control or large fingers, and they're a common cause of "I tapped the wrong button."

button, a {
  min-width: 44px;
  min-height: 44px;
  padding: 8px 12px;     /* combined with line-height, gets you to 44 */
}

The icon-button trap

<!-- 24px icon = 24px target. BAD. -->
<button><svg width="24" height="24">…</svg></button>

Fix: pad the button so its hit area is 44×44, even though the visual icon is 24×24:

button.icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
}

Spacing between targets

Two 44px buttons RIGHT next to each other still risk mis-taps. Industry rule: at least 8px between adjacent interactive elements.

When 24px IS OK

Dense desktop UIs (data tables with action icons, code editors) sometimes use smaller targets because the user is on a mouse with pixel-precision pointing. WCAG carves out an exception ("the target is part of a sentence or block of text"). For mobile-first or general-purpose UI, 44px is the floor.

🔒

Зарегистрируйся чтобы кодить

Теория открыта всем. Интерактивный редактор, живой превью и проверка открываются с 7-дневным бесплатным trial — нужна карта, отмена в любое время.

Регистрация — бесплатный trial →

Первые 10 уроков в каждом треке — бесплатные. Карта не нужна.

← НазадСледующий урок →

Получай один совет по Python или веб-разработке — каждый день в почте

Коротко, без воды, без спама. Отписаться — в один клик.