0Pricing
Web Accessibility Academy · Lección

aria-label frente a aria-labelledby

Elija entre un nombre en línea y uno referenciado.

aria-label frente a aria-labelledby es una lección gratuita de Web Accessibility Academy en CoddyKit. Esta es la lección 2 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Web Accessibility Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Web Accessibility Academy incluye 4 lecciones en total.

Partes de esta lección aún no han sido traducidas y se muestran en inglés.

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. 🎯

Preguntas frecuentes

¿La lección «aria-label frente a aria-labelledby» es gratis?

Sí — el texto completo de «aria-label frente a aria-labelledby» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Web Accessibility Academy, actualiza a CoddyKit PRO. El curso de Web Accessibility Academy incluye 4 lecciones en total.

¿Qué aprenderé en «aria-label frente a aria-labelledby»?

Elija entre un nombre en línea y uno referenciado. Practicas Web Accessibility Academy con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.

¿Necesito experiencia previa para empezar Web Accessibility Academy?

No se requiere experiencia previa. Web Accessibility Academy en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 2 de 4.

¿Cuánto tiempo toma la lección «aria-label frente a aria-labelledby»?

La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.

¿Puedo escribir y ejecutar código en esta lección de Web Accessibility Academy?

Sí. Cada lección de Web Accessibility Academy incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.

Todas las lecciones de este curso

  1. El cálculo del nombre accesible, explicado
  2. aria-label frente a aria-labelledby
  3. aria-describedby para contexto adicional
  4. Errores comunes de nomenclatura que silencian controles
← Volver a Web Accessibility Academy