Кнопки со значками, у которых всё ещё есть имя
Давайте кнопке без текста понятную доступную подпись.
«Кнопки со значками, у которых всё ещё есть имя» — бесплатный урок Web Accessibility Academy на CoddyKit. Это урок 3 из 4. Ты можешь прочитать весь урок бесплатно ниже — а потом практиковать его прямо в браузере с встроенным редактором кода и ИИ-репетитором 24/7. Это часть пути обучения Web Accessibility Academy, и твой прогресс синхронизируется между веб-версией и приложением CoddyKit. Курс Web Accessibility Academy содержит 4 уроков всего.
Части этого урока еще не переведены и отображаются на английском.
The Silent Button Problem
A button with only an icon inside looks clear to the eye, but a screen reader may just say button with no clue what it does. 🔇
Every Control Needs a Name
Every interactive control must have an accessible name. For text buttons the text supplies it; an icon-only button has no text to borrow.
Add aria-label to the Button
The simplest fix: put aria-label on the button itself to name the action, even when the inside is just an icon.
<button aria-label="Close">
<svg aria-hidden="true">...</svg>
</button>Hide the Icon Inside
Mark the inner icon with aria-hidden="true". The button carries the name; the icon is pure decoration once the label exists.
<button aria-label="Search">
<svg aria-hidden="true" focusable="false">...</svg>
</button>Or Use Visually Hidden Text
Prefer real text? Add a span styled with a visually-hidden class. Sighted users see only the icon; screen readers hear the words.
<button>
<svg aria-hidden="true">...</svg>
<span class="sr-only">Add to cart</span>
</button>What sr-only CSS Looks Like
A visually-hidden class clips the text to a single pixel without using display none, which would also hide it from screen readers.
.sr-only {
position: absolute;
width: 1px; height: 1px;
clip-path: inset(50%);
}Name the Action, Not the Icon
Label what happens, not the picture. Use Delete, not trash can. Users want the verb, not a description of the glyph.
Never Use the title Attribute Alone
The HTML title attribute is unreliable as a name: it skips touch and keyboard users entirely. Use aria-label or hidden text instead.
Toggle Buttons Need State
For an icon toggle like mute, also add aria-pressed so the button announces whether it is currently on or off.
<button aria-label="Mute" aria-pressed="false">
<svg aria-hidden="true">...</svg>
</button>Keep the Name in Sync
If an icon button changes meaning, update its name too. A play button that became pause must now announce Pause, not Play.
Verify the Spoken Name
In the accessibility inspector, select the button and read its computed name. It should match the action, never be blank.
Quick Check
You have a button containing only a magnifier SVG and no text. How do you give it an accessible name?
Recap: Name Every Icon Button
Give icon-only buttons a name via aria-label or visually hidden text, hide the icon, and label the action. Now every button speaks. ✅
Часто задаваемые вопросы
Урок «Кнопки со значками, у которых всё ещё есть имя» бесплатный?
Да — полный текст урока «Кнопки со значками, у которых всё ещё есть имя» бесплатно доступен здесь в веб-версии. Чтобы практиковать его интерактивно (встроенный редактор кода и ИИ-репетитор 24/7) и разблокировать остальной курс Web Accessibility Academy, подпишись на CoddyKit PRO. Курс Web Accessibility Academy содержит 4 уроков всего.
Чему я научусь в уроке «Кнопки со значками, у которых всё ещё есть имя»?
Давайте кнопке без текста понятную доступную подпись. Ты практикуешь Web Accessibility Academy с помощью реального кода, который запускаешь прямо в браузере, и ИИ-репетитор 24/7 отвечает на твои вопросы во время урока.
Нужен ли мне опыт, чтобы начать Web Accessibility Academy?
Предыдущий опыт не требуется. Web Accessibility Academy на CoddyKit структурирован для всех уровней — от новичков до продвинутых, поэтому ты можешь начать отсюда или с самого начала и учиться в своем темпе. Это урок 3 из 4.
Сколько времени занимает урок «Кнопки со значками, у которых всё ещё есть имя»?
Большинство уроков CoddyKit занимают около 5–10 минут. Каждый из них компактный и интерактивный, поэтому ты постоянно делаешь прогресс и продолжаешь с того же места в веб-версии и приложении.
Можно ли писать и запускать код в этом уроке Web Accessibility Academy?
Да. Каждый урок Web Accessibility Academy включает встроенный редактор кода, поэтому ты пишешь и запускаешь реальный код прямо в браузере и получаешь моментальную обратную связь от AI — локальная установка не требуется.
Все уроки этого курса
- Встроенный SVG: роль img и заголовок
- Скрытие декоративных значков с помощью aria-hidden
- Кнопки со значками, у которых всё ещё есть имя
- Шрифты значков и их проблемы с доступностью