The traditional two-letter code for the Chinese language is zh (ISO 639-1). It is the standard language code used in web development, software localization, and metadata systems to identify Chinese content. However, the story is more nuanced: because Chinese is a family of dialects and writing systems, other codes like cmn (Mandarin) and yue (Cantonese) exist for more specific identification.
What the Two-Letter Code Means
The zh code comes from the ISO 639-1 standard, which assigns two-letter identifiers to major languages. The abbreviation derives from Zhongwen (中文), the Chinese word for the Chinese language. In practice, zh is used in:
- HTML
langattributes (e.g.,lang="zh") - HTTP
Accept-Languageheaders - File and database locale identifiers
- Translation and localization tools
It is the most widely recognized code, but it is also the most ambiguous because it does not specify whether the text is Simplified or Traditional Chinese, nor which spoken dialect it represents.
Background: Why Chinese Has Multiple Codes
Chinese is not a single monolithic language. It is a branch of the Sino-Tibetan family with hundreds of spoken varieties. The written language, however, is largely unified in grammar, with two main script variants: Simplified (used in mainland China and Singapore) and Traditional (used in Taiwan, Hong Kong, and Macau). This split created the need for more specific codes.
ISO 639-2 and ISO 639-3 provide three-letter codes for languages and dialects. For Chinese, the most relevant are:
- cmn – Mandarin (the official spoken standard)
- yue – Cantonese
- wuu – Wu (including Shanghainese)
- hak – Hakka
- nan – Min Nan (including Hokkien and Taiwanese)
In addition, the IETF language tags standard (BCP 47) allows combining codes, such as zh-Hans for Simplified Chinese and zh-Hant for Traditional Chinese.
How the Codes Are Used in Practice
When you build a website or an app, you often need to specify the language of your content. The two-letter code zh is the default for any Chinese content, but for better user experience, you should use region or script subtags:
zh-CN– Simplified Chinese as used in mainland Chinazh-TW– Traditional Chinese as used in Taiwanzh-HK– Traditional Chinese as used in Hong Kongzh-Hans– Simplified Chinese (script only, no region)zh-Hant– Traditional Chinese (script only, no region)
These tags are used in HTML, in operating system locale settings, and in translation memory tools. For example, a website targeting Hong Kong readers would set lang="zh-HK" to ensure proper font rendering and regional terminology.
How to Choose the Right Code
Choosing the correct code depends on your audience and the nature of your content. Here are simple guidelines:
- If you only need a generic label, use zh.
- If you are writing for a specific region, use the region subtag (e.g.,
zh-SGfor Singapore). - If you need to specify the script (Simplified vs. Traditional), use
zh-Hansorzh-Hant. - If you are dealing with a specific spoken dialect (e.g., Cantonese audio), use the ISO 639-3 code like
yue.
For most web content, zh-CN and zh-TW are the most common choices because they implicitly cover both script and region.
Common Problems and Misconceptions
One common misconception is that zh stands for “Chinese” in the same way en stands for “English.” It does, but the lack of specificity can cause issues. For instance, a browser that sees lang="zh" may not know which font to use for characters that differ between Simplified and Traditional. Another issue is that some systems mistakenly use ch or cn as codes. cn is actually the country code for China, not a language code. Using cn in a language context is incorrect and can lead to misrouting of content.
Another problem is that older systems may not recognize newer codes like cmn. While ISO 639-3 is comprehensive, many applications still only support ISO 639-1. In such cases, you must fall back to zh.
Comparison: zh vs. cmn vs. yue
Here is a quick comparison of the three most common Chinese codes:
- zh – Broadest code, covers all Chinese languages and scripts. Best for general use.
- cmn – Specifically Mandarin, the official spoken language. Used in linguistic databases and speech technology.
- yue – Specifically Cantonese. Used for Cantonese content, especially in Hong Kong and overseas Chinese communities.
In practice, zh is the only code that is universally recognized by browsers and operating systems. The three-letter codes are more precise but less supported.
Costs and Practical Considerations
Using the correct language code is free, but getting it wrong can cost you in user experience and SEO. For example, if you serve Simplified Chinese text with a zh-TW tag, search engines may misidentify your target audience, and users may see incorrect font rendering. There is no financial cost to changing the code, but there is a technical cost: you must update all your HTML tags, HTTP headers, and possibly your database schema.
For translation projects, the code affects how translation memory tools match content. If you mix codes, you may end up with duplicate translations or missing ones. It is best to standardize on one code per project.
Template for Language Code Declaration
| Field | Value |
|---|---|
| Language code (ISO 639-1) | zh |
| Script subtag (optional) | Hans or Hant |
| Region subtag (optional) | CN, TW, HK, SG |
| Full IETF tag | zh-Hans-CN |
Sample (fictional): For a website targeting Simplified Chinese readers in Singapore, use lang="zh-Hans-SG".
Frequently Asked Questions
Is the two-letter code for Chinese “cn”?
No. cn is the two-letter country code for China (ISO 3166-1). The language code is zh. Some people mistakenly use cn because they think of China, but it is not a valid language code.
What does “zh” stand for?
It comes from Zhongwen (中文), the Chinese word for the Chinese language. The ISO 639-1 standard often uses the endonym (the name in the language itself) for codes.
Do I need to use “zh-Hans” or “zh-CN” for Simplified Chinese?
Both are acceptable, but they mean slightly different things. zh-Hans specifies the script only, while zh-CN implies the region (mainland China) and, by extension, Simplified Chinese. For maximum clarity, you can combine both: zh-Hans-CN.
Can I use “cmn” in an HTML lang attribute?
Technically, yes, but it is not widely supported. Most browsers and assistive technologies expect ISO 639-1 codes. If you use cmn, some systems may not recognize it. Stick to zh for broad compatibility.
What code should I use for Cantonese?
For Cantonese, use yue (ISO 639-3) or zh-yue in IETF format. However, be aware that not all systems support it. In practice, many Cantonese websites simply use zh-HK because Hong Kong uses Traditional Chinese and Cantonese is the dominant spoken language.
Final Thoughts on Chinese Language Codes
The two-letter code zh is the traditional and most widely used code for Chinese. It is simple, standardized, and sufficient for most purposes. When you need more precision, combine it with script or region subtags. Understanding the difference between language codes and country codes is crucial for correct implementation. By following the guidelines above, you can ensure your Chinese content is properly identified and displayed to the right audience.