aria-label と aria-labelledby
インラインで指定する名前と参照する名前を使い分けます。
「aria-label と aria-labelledby」はCoddyKit上の無料Web Accessibility Academyレッスンです。 これはレッスン2/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはWeb Accessibility Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Web Accessibility Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
Two Ways to Name
When native labeling is not enough, you have two ARIA tools: aria-label for an inline string, and aria-labelledby to point at existing text.
aria-label Holds a String
Use aria-label when there is no visible text to borrow. You type the spoken name right on the element itself.
<button aria-label="Search">🔍</button>aria-labelledby Holds an ID
Use aria-labelledby when visible text on the page can serve as the name. Its value is the id of that element, not a string.
<h2 id="sec">Billing</h2>
<section aria-labelledby="sec">...</section>Prefer Visible Text
Reach for aria-labelledby first. Reusing on-screen text keeps the spoken name and the visible name in sync automatically.
labelledby Can Combine IDs
Give aria-labelledby several ids separated by spaces, and the browser joins their text in that order into one name.
<span aria-labelledby="verb noun">Go</span>
<span id="verb">Delete</span> <span id="noun">file</span>labelledby Beats label
If both are present, aria-labelledby wins. The browser ignores aria-label entirely, so never expect them to merge.
An Element Can Name Itself
With aria-labelledby an element may reference its own id, which is handy for naming a region by its visible heading text.
label Is Invisible
An aria-label never appears on screen. It changes only what assistive tech announces, so sighted users see no difference.
Watch the Translation Trap
An aria-label is plain text that page translators often skip, while labelledby reuses visible content that does get translated.
IDs Must Match Exactly
An aria-labelledby id has to match a real element id. A typo silently leaves the element with no computed name at all.
Pick By Source of Truth
Ask where the name lives. If it is already on screen, use aria-labelledby; if it exists only for assistive tech, use aria-label.
Quick Check
A section already shows an h2 heading. How should you name the section?
Recap: label or labelledby
You learned to use aria-labelledby for existing visible text and aria-label for invisible inline names, never expecting them to combine. 🎯
よくある質問
「aria-label と aria-labelledby」レッスンは無料ですか?
はい。「aria-label と aria-labelledby」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Web Accessibility Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Web Accessibility Academyコースには全4レッスンが含まれています。
「aria-label と aria-labelledby」で何を学びますか?
インラインで指定する名前と参照する名前を使い分けます。 ブラウザで直接実行するハンズオンコードでWeb Accessibility Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Web Accessibility Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのWeb Accessibility Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン2/4です。
「aria-label と aria-labelledby」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このWeb Accessibility Academyレッスンでコードを書いて実行できますか?
はい。すべてのWeb Accessibility Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- アクセシブルネームの計算をわかりやすく解説
- aria-label と aria-labelledby
- 追加情報に使う aria-describedby
- コントロールを無名にするよくある命名ミス