HTML Country Code

Beginner
⏱️ 8 min read
📚 Updated: Jul 2026
🎯 3 Try It + 238 codes
ISO 3166-1

Introduction

When you build international websites, checkout forms, or signup flows, you often need a standard way to identify countries. HTML does not ship its own country list—developers use ISO 3166-1 alpha-2 codes (two letters) in markup, forms, and JavaScript.

This guide explains what those codes are, how to use them in HTML, and provides a complete reference table plus Try It demos with plain HTML and no CSS.

What You’ll Learn

01

ISO alpha-2

Two letters.

02

Forms

Select options.

03

data-country

Custom attrs.

04

Full list

238 codes.

05

vs lang

Not the same.

06

Examples

Real markup.

What is HTML Country Code?

HTML does not have specific country codes defined within its standard.

However, when it comes to specifying country-related information within HTML, the commonly accepted approach is to use ISO 3166-1 alpha-2 country codes.

These are two-letter codes that represent countries and are widely used across various systems and standards.

For example, if you need to indicate the country of a user or display country-specific information, you can use ISO 3166-1 alpha-2 country codes within your HTML markup or JavaScript code.

💡
Beginner Tip

Store the code (US) as the value in forms and the country name as visible text: <option value="US">United States</option>.

Country Code Example in HTML

Here’s an example of how you can use country codes in HTML:

html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>HTML Country Code Example</title>
</head>
<body>
  <h1>Welcome to our website!</h1>
  <p>We are pleased to serve customers from different countries.</p>

  <div class="country-info" data-country="US">
    <h2>United States</h2>
    <p>This section contains specific information for customers in the United States.</p>
  </div>

  <div class="country-info" data-country="GB">
    <h2>United Kingdom</h2>
    <p>This section contains specific information for customers in the United Kingdom.</p>
  </div>

  <script>
    var countryDivs = document.getElementsByClassName('country-info');
    for (var i = 0; i < countryDivs.length; i++) {
      var countryDiv = countryDivs[i];
      var country = countryDiv.getAttribute('data-country');
      if (country === 'US') {
        // Do something for the United States
      } else if (country === 'GB') {
        // Do something for the United Kingdom
      } else {
        // Handle other countries
      }
    }
  </script>
</body>
</html>

⚡ Quick Reference — Popular Codes

United States
US
United Kingdom
GB
India
IN
Canada
CA
Australia
AU
Germany
DE

ISO 3166-1 Alpha-2 Country Codes

Here are ISO 3166-1 alpha-2 country codes for reference (238 entries):

CountryISO Code
AfghanistanAF
AlbaniaAL
AlgeriaDZ
American SamoaAS
AndorraAD
AngolaAO
AntarcticaAQ
Antigua And BarbudaAG
ArgentinaAR
ArmeniaAM
ArubaAW
AustraliaAU
AustriaAT
AzerbaijanAZ
BahamasBS
BahrainBH
BangladeshBD
BarbadosBB
BelarusBY
BelgiumBE
BelizeBZ
BeninBJ
BermudaBM
BhutanBT
BoliviaBO
Bosnia And HerzegovinaBA
BotswanaBW
Bouvet IslandBV
BrazilBR
British Indian Ocean TerritoryIO
Brunei DarussalamBN
BulgariaBG
Burkina FasoBF
BurundiBI
CambodiaKH
CameroonCM
CanadaCA
Cape VerdeCV
Cayman IslandsKY
Central African RepublicCF
ChadTD
ChileCL
ChinaCN
Christmas IslandCX
Cocos (Keeling) IslandsCC
ColombiaCO
ComorosKM
CongoCG
Congo, The Democratic Republic Of TheCD
Cook IslandsCK
Costa RicaCR
Côte D'ivoireCI
CroatiaHR
CubaCU
CyprusCY
Czech RepublicCZ
DenmarkDK
DjiboutiDJ
DominicaDM
Dominican RepublicDO
EcuadorEC
EgyptEG
El SalvadorSV
Equatorial GuineaGQ
EritreaER
EstoniaEE
EthiopiaET
Falkland Islands (Malvinas)FK
Faroe IslandsFO
FijiFJ
FinlandFI
FranceFR
French GuianaGF
French PolynesiaPF
French Southern TerritoriesTF
GabonGA
GambiaGM
GeorgiaGE
GermanyDE
GhanaGH
GibraltarGI
GreeceGR
GreenlandGL
GrenadaGD
GuadeloupeGP
GuamGU
GuatemalaGT
GuineaGN
Guinea-BissauGW
GuyanaGY
HaitiHT
Heard Island And Mcdonald IslandsHM
HondurasHN
Hong KongHK
HungaryHU
IcelandIS
IndiaIN
IndonesiaID
Iran, Islamic Republic OfIR
IraqIQ
IrelandIE
IsraelIL
ItalyIT
JamaicaJM
JapanJP
JordanJO
KazakhstanKZ
KenyaKE
KiribatiKI
Korea, Democratic People's Republic OfKP
Korea, Republic OfKR
KuwaitKW
KyrgyzstanKG
Lao People's Democratic Republic(Laos)LA
LatviaLV
LebanonLB
LesothoLS
LiberiaLR
Libyan Arab JamahiriyaLY
LiechtensteinLI
LithuaniaLT
LuxembourgLU
MacaoMO
Macedonia, The Former Yugoslav Republic OfMK
MadagascarMG
MalawiMW
MalaysiaMY
MaldivesMV
MaliML
MaltaMT
Marshall IslandsMH
MartiniqueMQ
MauritaniaMR
MauritiusMU
MayotteYT
MexicoMX
Micronesia, Federated States OfFM
Moldova, Republic OfMD
MonacoMC
MongoliaMN
MontenegroME
MontserratMS
MoroccoMA
MozambiqueMZ
MyanmarMM
NamibiaNA
NauruNR
NepalNP
NetherlandsNL
Netherlands AntillesAN
New CaledoniaNC
New ZealandNZ
NicaraguaNI
NigerNE
NigeriaNG
NiueNU
Norfolk IslandNF
Northern Mariana IslandsMP
NorwayNO
OmanOM
PakistanPK
PalauPW
Palestinian Territory, OccupiedPS
PanamaPA
Papua New GuineaPG
ParaguayPY
PeruPE
PhilippinesPH
PitcairnPN
PolandPL
PortugalPT
Puerto RicoPR
QatarQA
RéunionRE
RomaniaRO
Russian FederationRU
RwandaRW
Saint HelenaSH
Saint Kitts And NevisKN
Saint LuciaLC
Saint Pierre And MiquelonPM
Saint Vincent And The GrenadinesVC
SamoaWS
San MarinoSM
Sao Tome And PrincipeST
Saudi ArabiaSA
SenegalSN
SerbiaRS
SeychellesSC
Sierra LeoneSL
SingaporeSG
SlovakiaSK
SloveniaSI
Solomon IslandsSB
SomaliaSO
South AfricaZA
South Georgia And The South Sandwich IslandsGS
SpainES
Sri LankaLK
SudanSD
SurinameSR
Svalbard And Jan MayenSJ
SwazilandSZ
SwedenSE
SwitzerlandCH
Syrian Arab RepublicSY
TaiwanTW
TajikistanTJ
Tanzania, United Republic OfTZ
ThailandTH
Timor-LesteTL
TogoTG
TokelauTK
TongaTO
Trinidad And TobagoTT
TunisiaTN
TurkeyTR
TurkmenistanTM
Turks And Caicos IslandsTC
TuvaluTV
UgandaUG
UkraineUA
United Arab EmiratesAE
United KingdomGB
United StatesUS
United States Minor Outlying IslandsUM
UruguayUY
UzbekistanUZ
VanuatuVU
VenezuelaVE
Viet NamVN
Virgin Islands, BritishVG
Virgin Islands, U.S.VI
Wallis And FutunaWF
Western SaharaEH
YemenYE
ZambiaZM
ZimbabweZW

You can use these country codes in various contexts, such as within form fields, data attributes, or JavaScript functions, to handle country-specific logic or display relevant information.

It’s important to note that while ISO 3166-1 alpha-2 codes are widely used, they might not cover all geopolitical entities or regions. In some cases, there are additional codes defined for specific regions or territories.

Examples Gallery

Three Try It demos: a country <select>, data-country sections, and the full reference page pattern.

Example 1 — Country Select Dropdown

html
<select name="country">
  <option value="US">United States</option>
  <option value="GB">United Kingdom</option>
  <option value="IN">India</option>
</select>
Try It Yourself

Example 2 — data-country Attribute

html
<div data-country="US">US content</div>
<div data-country="GB">UK content</div>
Try It Yourself

🚀 Common Use Cases

  • Checkout forms — shipping and billing country fields.
  • Phone inputs — pair country code with dial prefix (+1, +44).
  • Localization — show prices in local currency by country.
  • Compliance — GDPR, tax rules, or age gates by region.
  • Analytics — segment users by ISO country code.
  • hreflang / SEO — combine with language for en-US, en-GB.

Best Practices

  • Use ISO alpha-2 — stick to the standard two-letter codes for interoperability.
  • Store codes, display names — submit US to the server, show “United States” to users.
  • Sort for users — list countries alphabetically by localized name, not by code.
  • Do not confuse with lang — country is not language; see HTML lang attribute.
  • Keep lists updated — ISO occasionally adds or changes codes; refresh your data source periodically.

Conclusion

Country codes in HTML are really ISO 3166-1 alpha-2 codes used inside your markup and scripts. They power international forms, regional content, and APIs across the web.

Bookmark the table above as your reference, try the demos in the editor, and continue with HTML language codes (lang) for declaring page language.

❓ Frequently Asked Questions

HTML does not define its own country codes. In web development, country codes usually mean ISO 3166-1 alpha-2 — two-letter codes like US for United States, GB for United Kingdom, and IN for India.
Common places: value attributes on option elements in a select dropdown, data-country attributes on elements, form field names submitted to a server, and JavaScript for showing region-specific content.
It is an international standard of two-letter country codes maintained by the ISO. It is used by HTML forms, APIs, payment systems, and the lang attribute region subtag (e.g. en-US).
No. Country codes identify nations (US, FR). Language codes identify languages (en, fr). They are often combined in BCP 47 tags like en-US (English as used in the United States).
For HTML forms and most web APIs, alpha-2 (two letters) is standard. Alpha-3 (three letters, e.g. USA) appears in some databases but is less common in front-end markup.
Use a select element with option value set to the ISO code and visible text set to the country name. Load options from this reference table or a maintained JSON list.
Did you know?

The lang attribute can include a region subtag that uses the same ISO country codes: lang="en-US" means English as used in the United States, while lang="en-GB" is British English.

Try a country select in the editor

Pick a country from the dropdown and see its ISO alpha-2 code—plain HTML, no CSS.

Open Try It editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful