Skip to main content
HTML Validation

Bad value “yaml” for attribute “lang” on element “code”: Found reserved language tag: “yaml”.

About This HTML Issue

The language tag yaml is reserved by IANA and cannot be used as a value for the lang attribute, which expects a valid BCP 47 language tag (like en for English or fr for French).

The lang attribute specifies the natural language of an element’s content — human languages like English, Spanish, or Japanese. It is not meant to indicate a programming or markup language. When you write lang="yaml" on a <code> element, the validator rejects it because yaml is a reserved IANA subtag with no valid use in BCP 47.

If your goal is to identify the code language for syntax highlighting or styling purposes, use the class attribute instead. A common convention, recommended by the HTML specification itself, is to use a class prefixed with language-, such as class="language-yaml".

HTML Examples

❌ Invalid: using lang for code language

<pre>
  <code lang="yaml">
    name: my-project
    version: 1.0.0
  </code>
</pre>

✅ Valid: using class for code language

<pre>
  <code class="language-yaml">
    name: my-project
    version: 1.0.0
  </code>
</pre>

This class="language-*" convention is widely supported by syntax highlighting libraries like Prism.js and highlight.js.

Find issues like this automatically

Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.

Help us improve our guides

Was this guide helpful?
🌍 Trusted by teams worldwide

Validate at scale.
Ship accessible websites, faster.

Automated HTML & accessibility validation for large sites. Check thousands of pages against WCAG guidelines and W3C standards in minutes, not days.

Scheduled Reports
API Access
Open Source Standards
$7 / 7 days

Pro Trial

Full Pro access. Cancel anytime.

Start Pro Trial →

Join teams across 40+ countries