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

html-xml-lang-mismatch

하는 일

이 스킬은 페이지 html 요소의 언어 속성을 확인합니다. XHTML 페이지나 HTML과 XML 양쪽으로 작동해야 하는 페이지를 만드는 개발자를 위한 것입니다.

사용하는 경우

  • ✓페이지에서 lang과 xml:lang이 서로 다른 값으로 설정되어 있을 때.
  • ✓스크린 리더가 잘못된 언어 음성으로 텍스트를 읽을 때.
  • ✓XHTML이나 EPUB 형식의 문서를 게시할 때.

스킬 링크

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

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

사용 방법

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

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

Use this skill to help me: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/html-xml-lang-mismatch/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 요소의 lang과 xml:lang을 확인하고, 두 값이 같은 유효한 언어 코드인지 봅니다. en과 en-US처럼 하위 태그가 다른 경우도 불일치로 표시합니다.

기술 내용 (원본 SKILL.md)

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

Match lang and xml:lang attributes

Screen readers use the lang attribute to select the correct voice profile and pronunciation engine. If lang and xml:lang disagree, XML-based processors (including some EPUB readers and older assistive technologies) may use xml:lang and get a different language than intended — causing text to be read aloud in the wrong language. For example, French text read with an English voice profile produces unintelligible output for French-speaking blind users.

Quick Reference

  • If both lang and xml:lang are present on <html>, their values must be identical
  • xml:lang is only needed for XHTML or polyglot documents (valid as both HTML and XML)
  • For standard HTML5 documents, only lang is required — xml:lang is redundant
  • The primary language tag must be a valid BCP 47 language code (e.g., en, en-US, fr, zh-Hant)
  • Relates to WCAG 2.1 SC 3.1.1 (Language of Page)

Check

Inspect the <html> element for both lang and xml:lang attributes. If both are present, verify their values are identical (including subtags — en vs en-US is a mismatch). Also verify that the value is a valid BCP 47 language tag. Flag if the values differ in any way.

Fix

If lang and xml:lang are present but differ: update both to the same valid BCP 47 language code matching the primary language of the document content. If this is a standard HTML5 document (served as text/html), remove xml:lang — it is unnecessary. If this is XHTML or a polyglot document, keep both and ensure they are identical.

Explain

WCAG 2.1 SC 3.1.1 requires that the default human language of each web page can be programmatically determined. The lang attribute on <html> serves this purpose for HTML parsers. The xml:lang attribute serves the same purpose for XML parsers. When a document must be valid as both HTML and XML (polyglot), both attributes must be present and identical. A mismatch means the document claims different languages depending on which parser reads it, which can cause screen readers, translation tools, and spell checkers to use wrong language rules.

Code Review

Review the rendered markup and interactive states that affect Match lang and xml:lang attributes. Flag exact elements, roles, labels, focus behavior, or keyboard interactions that violate the rule, and note how to verify the fix with browser accessibility tooling or assistive tech.


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

Rule page: https://frontendchecklist.io/rules/accessibility/html-xml-lang-mismatch

자주 묻는 질문

일반 HTML5 페이지에도 xml:lang이 필요한가요?

아닙니다. 스킬은 표준 HTML5 페이지에는 lang만 있으면 되며, xml:lang은 그곳에서 중복이라고 설명합니다.

불일치가 왜 중요한가요?

일부 XML 도구와 오래된 보조 기술이 xml:lang을 읽을 수 있어, 잘못된 언어로 인식될 수 있습니다.

어떤 표준을 참고하나요?

WCAG 2.1 성공 기준 3.1.1 「페이지의 언어」 규칙을 인용합니다.

상세 정보

작성자의 원본 설명

Use when applies to XHTML documents and polyglot HTML documents that must parse correctly as both HTML5 and XML. For modern HTML5-only documents, only `lang` is needed and `xml:lang` is not required. Check when auditing documents served as application/xhtml+xml or documents that include both attributes.

repo: thedaviddias/Front-End-Checklist

인기도

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

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬