본문으로 건너뛰기
Skillpedia
웹사이트 및 UI (프런트엔드)75k · #2913

lang-attribute

하는 일

이 스킬은 페이지가 언어를 올바르게 선언하고, 다른 언어로 쓰인 부분이 표시되어 있는지 확인합니다. 모든 웹사이트의 개발자와 콘텐츠 편집자를 위한 것입니다.

사용하는 경우

  • ✓html 요소에 언어가 설정되어 있지 않을 때.
  • ✓스크린 리더가 텍스트를 잘못된 발음으로 읽을 때.
  • ✓페이지에 다른 언어로 쓰인 부분이 포함되어 있을 때.

스킬 링크

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/lang-attribute/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/lang-attribute/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“제 페이지가 언어를 올바르게 선언하고 있는지 확인해 주실 수 있나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 html 요소에 en이나 fr-CA 같은 유효한 lang 값이 있는지 확인합니다. 언어가 바뀌는 섹션에도 lang 속성을 제안합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Set the page lang attribute

Screen readers select the correct text-to-speech voice and pronunciation engine based on the lang attribute. Without it, VoiceOver defaults to the user's system language, and NVDA uses its default voice — both may mispronounce words in other languages, making content unintelligible. French text read with an English voice profile is incomprehensible. The lang attribute also enables browser translation features (Chrome's Translate), hyphenation algorithms (CSS hyphens: auto), and correct spell checking. This is a WCAG Level A requirement — the most fundamental accessibility baseline.

Quick Reference

  • The <html> element must have a lang attribute — WCAG 2.1 SC 3.1.1 (Language of Page, Level A)
  • The value must be a valid BCP 47 language tag: en, en-US, fr, zh-Hant, ar, etc.
  • Use lang on individual elements to indicate language changes within the page — WCAG 2.1 SC 3.1.2 (Level AA)
  • The lang attribute affects screen reader pronunciation, spell checking, hyphenation, and browser translation
  • An empty lang='' is treated as unknown language — equivalent to having no lang attribute

Check

Inspect the <html> element in the page source. Verify: (1) a lang attribute is present; (2) its value is non-empty; (3) its value is a valid BCP 47 language code matching the primary language of the page content (e.g., en for English, fr for French, zh-Hant for Traditional Chinese). Flag: missing lang, empty lang='', language codes using full names instead of codes (e.g., lang='english' is invalid), and mismatches where the declared language does not match the actual content language. For multilingual pages, also check for lang changes on block-level elements containing content in a different language.

Fix

Add or correct the lang attribute on the <html> element: <html lang='en'> for English, <html lang='fr'> for French, <html lang='es'> for Spanish, <html lang='de'> for German, <html lang='ja'> for Japanese, <html lang='zh-Hans'> for Simplified Chinese, <html lang='zh-Hant'> for Traditional Chinese, <html lang='ar'> for Arabic. For content sections in different languages, add lang to the containing block element. Validate language codes against the IANA Language Subtag Registry.

Explain

WCAG 2.1 SC 3.1.1 (Language of Page, Level A) requires that the default human language of each web page can be programmatically determined. The lang attribute on <html> fulfills this requirement. The value must be a BCP 47 language tag — a standardized system of subtags that identifies language, script, and region. The primary language subtag (e.g., en, fr) is required; region subtags (e.g., en-US, fr-CA) are optional but useful for dialect-specific pronunciation and spell checking. SC 3.1.2 (Language of Parts, Level AA) extends this to inline language changes within a page.

Code Review

Review templates, server-rendered HTML, and shared components that output markup related to Set the page lang attribute. Flag exact elements, attributes, and routes where the rendered HTML violates the rule.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/html/lang-attribute

자주 묻는 질문

lang이 스크린 리더에 왜 중요한가요?

스킬은 스크린 리더가 lang을 보고 올바른 음성과 발음을 고른다고 설명합니다.

어떤 값이 유효한가요?

en, en-US, fr, zh-Hant처럼 BCP 47 언어 코드로 된 값입니다.

lang이 비어 있으면 어떻게 되나요?

스킬은 빈 lang은 언어를 설정하지 않은 것과 같게 취급된다고 설명합니다.

상세 정보

작성자의 원본 설명

Use when applies to all HTML documents. Check the `<html>` opening tag for a `lang` attribute with a non-empty, valid BCP 47 language code. Also check for `lang` attribute changes on individual elements when the document contains content in multiple languages (inline quotes, foreign terms, multilingual sections). The `lang` attribute is inherited — child elements inherit the language from their nearest ancestor with `lang`.

repo: thedaviddias/Front-End-Checklist

인기도

GitHub 스타
75k
순위
#2913
라이선스
MIT
업데이트
2026. 10. 31.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬