# Bad value “csharp” for attribute “lang” on element “code”: The language subtag “csharp” is not a valid IANA language part of a language tag.

> Canonical HTML version: https://rocketvalidator.com/html-validation/bad-value-csharp-for-attribute-lang-on-element-code-the-language-subtag-csharp-is-not-a-valid-iana-language-part-of-a-language-tag
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

The `lang` attribute on any HTML element must be a valid IANA language subtag (like `en`, `fr`, or `ja`), not a programming language name.

The `lang` attribute specifies the **natural (human) language** of the element's content, used by browsers, screen readers, and search engines for accessibility and localization purposes. Values like `csharp`, `javascript`, or `python` are not valid because they are not human languages registered in the [IANA Language Subtag Registry](https://www.iana.org/assignments/language-subtags/language-subtags).

This issue commonly arises when using `<code lang="csharp">` to indicate the programming language of a code snippet. While the intention makes sense, `lang` is not the right attribute for this purpose.

To indicate a programming language on a `<code>` element, the recommended convention from the HTML specification is to use the `class` attribute with a `language-` prefix (e.g., `class="language-csharp"`). This is also the pattern used by popular syntax highlighting libraries like Prism.js and highlight.js.

If the code content is written in a specific human language (like English), you can still use `lang="en"` alongside the class.

## Bad Example

```html
<pre>
  <code lang="csharp">
    Console.WriteLine("Hello, World!");
  </code>
</pre>
```

## Good Example

```html
<pre>
  <code class="language-csharp">
    Console.WriteLine("Hello, World!");
  </code>
</pre>
```
