Introduction
In this article, we will learn how to add a country flag icon on a website using Angular and Bootstrap 4.
Prerequisites
- Node
- Npm
- Angular CLI
- TypeScript
- Visual Studio Code
Description
Here, I will show you the steps to add country flag icons on our website. Also, we can add flag icons for corresponding countries with languages for translating the website to other languages.
Note
Before going through this session, please visit my previous article related to Angular 7 application.
Step 1
In this step, we need to install the flag icon packages using NPM by using the below command.
npm install flag-icon-css
Step 2
After successful installation, the file structure in the node_modules folder should look like the below image. Here, we can get a collection of all country flags in SVG with the CSS for easier integration.

Step 3
Open the angular.json file and add the path of the flag icon CSS file under the Styles section, as mentioned below.
"node_modules/flag-icon-css/css/flag-icon.min.css"
Step 4
Open the app.component.html file and add the code mentioned below.
Code Ref
- <h2>
- India flag icon -> <span class="flag-icon flag-icon-in flag-icon-squared"></span>
- <br/>
- France flag icon -> <span class="flag-icon flag-icon-fr flag-icon-squared"></span>
- <br/>
- Australia flag icon -> <span class="flag-icon flag-icon-au flag-icon-squared"></span>
- <br/>
- United Kingdom flag icon -> <span class="flag-icon flag-icon-gb flag-icon-squared"></span>
- </h2>
Code Desc
In this section, for using the flags inline with text, add the classes .flag-icon and .flag-icon-xx (where xx is the ISO 3166-1-alpha-2 code of a country) to an empty <span>. If you want to have a squared version flag, then add the class flag-icon-squared. For example, I have added an Indian flag. The ISO 3166-1-alpha-2 code of India is "in" and this code should be case sensitive.
Here is the list of ISO 3166 country codes and flags for future reference.
| Country Name | ISO 3166 Country Code | Country Name | ISO 3166 Country Code |
|---|---|---|---|
Afghanistan |
AF | Albania |
AL |
Algeria |
DZ | Andorra |
AD |
Angola |
AO | Antigua and Barbuda |
AG |
Argentina |
AR | Armenia |
AM |
Australia |
AU | Austria |
AT |
Azerbaijan |
AZ | Bahamas |
BS |
Bahrain |
BH | Bangladesh |
BD |
Barbados |
BB | Belarus |
BY |
Belgium |
BE | Belize |
BZ |
Benin |
BJ | Bhutan |
BT |
Bolivia |
BO | Bosnia and Herz. |
BA |
Botswana |
BW | Brazil |
BR |
Brunei |
BN | Bulgaria |
BG |
Burkina Faso |
BF | Burundi |
BI |
Cambodia |
KH | Cameroon |
CM |
Canada |
CA | Cape Verde |
CV |
Central African Rep. |
CF | Chad |
TD |
Chile |
CL | China |
CN |
Colombia |
CO | Comoros |
KM |
Congo, The Democr. Rep. of the |
CD | Costa Rica |
CR |
Cote d'Ivoire |
CI | Croatia |
HR |
Cuba |
CU | Cyprus |
CY |
Czech Republic |
CZ | Denmark |
DK |
Djibouti |
DJ | Dominica |
DM |
Dominican Republic |
DO | East Timor |
TL |
Ecuador |
EC | Egypt |
EG |
El Salvador |
SV | Equatorial Guinea |
GQ |
Eritrea |
ER | Estonia |
EE |
Ethiopia |
ET | Fiji |
FJ |
Finland |
FI | France |
FR |
French Polynesia |
PF | Gabon |
GA |
Gambia, The |
GM | Georgia |
GE |
Germany |
DE | Ghana |
GH |
Gibraltar |
GI | Greece |
GR |
Greenland |
GL | Grenada |
GD |
Guadeloupe |
GP | Guatemala |
GT |
Guinea |
GN | Guinea-Bissau |
GW |
Guyana |
GY | Haiti |
HT |
Honduras |
HN | Hong Kong SAR |
HK |
Hungary |
HU | Iceland |
IS |
India |
IN | Indonesia |
ID |
Iran |
IR | Iraq |
IQ |
Ireland |
IE | Israel |
IL |
Italy |
IT | Jamaica |
JM |
Japan |
JP | Jordan |
JO |
Kazakhstan |
KZ | Kenya |
KE |
Kiribati |
KI | Korea, North |
KP |
Korea, South |
KR | Kuwait |
KW |
Kyrgyzstan |
KG | Laos |
LA |
Latvia |
LV | Lebanon |
LB |
Lesotho |
LS | Liberia |
LR |
Libya |
LY | Liechtenstein |
LI |
Lithuania |
LT | Luxembourg |
LU |
Macau SAR |
MO | Macedonia |
MK |
Madagascar |
MG | Malawi |
MW |
Malaysia |
MY | Maldives |
MV |
Mali |
ML | Malta |
MT |
Marshall Islands |
MH | Martinique |
MQ |
Mauritania |
MR | Mauritius |
MU |
Mexico |
MX | Micronesia, Fed. States of |
FM |
Moldova |
MD | Monaco |
MC |
Mongolia |
MN | Montenegro |
ME |
Morocco |
MA | Mozambique |
MZ |
Myanmar |
MM | Namibia |
NA |
Nauru |
NR | Nepal |
NP |
Netherlands |
NL | New Caledonia |
NC |
New Zealand |
NZ | Nicaragua |
NI |
Niger |
NE | Nigeria |
NG |
Northern Mariana Islands |
MP | Norway |
NO |
Oman |
OM | Pakistan |
PK |
Palau |
PW | Palestinian Territories |
PS |
Panama |
PA | Papua New Guinea |
PG |
Paraguay |
PY | Peru |
PE |
Philippines |
PH | Poland |
PL |
Portugal |
PT | Puerto Rico |
PR |
Qatar |
QA | Réunion |
RE |
Romania |
RO | Russian Federation |
RU |
Rwanda |
RW | Saint Kitts and Nevis |
KN |
Saint Lucia |
LC | Samoa |
WS |
San Marino |
SM | Sao Tome and Princ. |
ST |
Saudi Arabia |
SA | Senegal |
SN |
Serbia |
RS | Seychelles |
SC |
Sierra Leone |
SL | Singapore |
SG |
Slovakia |
SK | Slovenia |
SI |
Solomon Islands |
SB | Somalia |
SO |
South Africa |
ZA | Spain |
ES |
Sri Lanka |
LK | St Vincent and Gren. |
VC |
Sudan |
SD | Suriname |
SR |
Swaziland |
SZ | Sweden |
SE |
Switzerland |
CH | Syria |
SY |
Taiwan |
TW | Tajikistan |
TJ |
Tanzania |
TZ | Thailand |
TH |
Togo |
TG | Tonga |
TO |
Trinidad and Tobago |
TT | Tunisia |
TN |
Turkey |
TR | Turkmenistan |
TM |
Tuvalu |
TV | Uganda |
UG |
Ukraine |
UA | United Arab Emirates |
AE |
United Kingdom |
GB | United States |
US |
Uruguay |
UY | Uzbekistan |
UZ |
Vanuatu |
VU | Vatican City |
VA |
Venezuela |
VE | Vietnam |
VN |
Virgin Islands, British |
VG | Virgin Islands, U.S. |
VI |
Western Sahara |
EH | Yemen |
YE |
Zambia |
ZM | Zimbabwe |
ZW |
OUTPUT

Step 5
In this step, we should apply this flag icon in our previous Angular 7 series application. Open the home.component.html file and add code as mentioned below.
<h1>Satyaprakash Samantaray <span class="flag-icon flag-icon-in flag-icon-squared"></span></h1>
OUTPUT
Summary
In this article, we have learned:
- Steps to add flag icon in Angular app;
- Scenarios where we can implement this in our project
- List of ISO 3166 country codes and flags
- Customization of country flags in SVG with CSS after installation

Afghanistan
Albania
Algeria
Andorra
Angola
Antigua and Barbuda
Argentina
Armenia
Australia
Austria
Azerbaijan
Bahamas
Bahrain
Bangladesh
Barbados
Belarus
Belgium
Belize
Benin
Bhutan
Bolivia
Bosnia and Herz.
Botswana
Brazil
Brunei
Bulgaria
Burkina Faso
Burundi
Cambodia
Cameroon
Canada
Cape Verde
Central African Rep.
Chad
Chile
China
Colombia
Comoros
Congo, The Democr. Rep. of the
Costa Rica
Cote d'Ivoire
Croatia
Cuba
Cyprus
Czech Republic
Denmark
Djibouti
Dominica
Dominican Republic
East Timor
Ecuador
Egypt
El Salvador
Equatorial Guinea
Eritrea
Estonia
Ethiopia
Fiji
Finland
France
French Polynesia
Gabon
Gambia, The
Georgia
Germany
Ghana
Gibraltar
Greece
Greenland
Grenada
Guadeloupe
Guatemala
Guinea
Guinea-Bissau
Guyana
Haiti
Honduras
Hong Kong SAR
Hungary
Iceland
India
Indonesia
Iran
Iraq
Ireland
Israel
Italy
Jamaica
Japan
Jordan
Kazakhstan
Kenya
Kiribati
Korea, North
Korea, South
Kuwait
Kyrgyzstan
Laos
Latvia
Lebanon
Lesotho
Liberia
Libya
Liechtenstein
Lithuania
Luxembourg
Macau SAR
Macedonia
Madagascar
Malawi
Malaysia
Maldives
Mali
Malta
Marshall Islands
Martinique
Mauritania
Mauritius
Mexico
Micronesia, Fed. States of
Moldova
Monaco
Mongolia
Montenegro
Morocco
Mozambique
Myanmar
Namibia
Nauru
Nepal
Netherlands
New Caledonia
New Zealand
Nicaragua
Niger
Nigeria
Northern Mariana Islands
Norway
Oman
Pakistan
Palau
Palestinian Territories
Panama
Papua New Guinea
Paraguay
Peru
Philippines
Poland
Portugal
Puerto Rico
Qatar
Réunion
Romania
Russian Federation
Rwanda
Saint Kitts and Nevis
Saint Lucia
Samoa
San Marino
Sao Tome and Princ.
Saudi Arabia
Senegal
Serbia
Seychelles
Sierra Leone
Singapore
Slovakia
Slovenia
Solomon Islands
Somalia
South Africa
Spain
Sri Lanka
St Vincent and Gren.
Sudan
Suriname
Swaziland
Sweden
Switzerland
Syria
Taiwan
Tajikistan
Tanzania
Thailand
Togo
Tonga
Trinidad and Tobago
Tunisia
Turkey
Turkmenistan
Tuvalu
Uganda
Ukraine
United Arab Emirates
United Kingdom
United States
Uruguay
Uzbekistan
Vanuatu
Vatican City
Venezuela
Vietnam
Virgin Islands, British
Virgin Islands, U.S.
Western Sahara
Yemen
Zambia
Zimbabwe
Sachin SboaPosted Jul 27, 2019, 11:45 AM
Good one....
Amit Kumar SinghPosted Apr 29, 2019, 10:42 PM
Thanks !!!
Sarathlal SaseendranPosted Apr 29, 2019, 2:22 PM
As usual, wonderful article Satya.