<input type="country" />
Recently, Lea Verou asked an important question about whether HTML should have a standardised way of letting users select a country from a list.
You can read through the conversation and make your own mind up (while also marvelling at the witless mansplainers) - but I'd like to give you my considered take on it.
(Disclaimer - I'm an editor on the HTML 5.3 spec and I work for the UK Government. This is a personal blog post and doesn't represent the views of my employers, associates, or friends.)
Who Are You?
Let's start with the big one. What is a country? This is about as contentious as it gets! It involves national identities, international politics, and hereditary relationships.
Scotland, for example, is a country. That is a (fairly) uncontentious statement - and yet in drop-down lists, I rarely see it mentioned. Why? Because it is one of the four countries which make up the country of the United Kingdom - and so it is usually (but not always) subsumed into that.
Some countries don't recognise each other. Some believe that the other country is really part of their country. Some countries don't exist.
There are two main schemes to classify what is and isn't a country. The first is ISO 3166-1. It provides two- and three-letter codes for every country. Well... sort of.
ISO 3166 contains 249 different countries, territories, protectorates, principalities, duchies, and other bits-and-bobs. It contains the Falklands, but not Scotland.
The second is... whatever your country says is another country!
My friends in the Government Registers Team have published a canonical list of every country that the UK recognises. There are 199 entries. Which countries are not in there is left as an exercise for the reader.
The UK's register of countries should allow every Government website to have the same list in a drop down. When new countries are recognised, one list needs to be updated - and then all websites automagically update. In theory.
Incidentally, that list of 199 countries includes four entries for countries which no-longer exist. For example Yugoslavia.
Which brings us to the next question...
What's the use case?
The most obvious one is "I want to give a site my current address" - presumably for identification purposes or postal deliveries.
But what if the use case is "I want to say where I was born"?
Borders shift. Countries disappear, merge, split, change names, change flags, and do all manner of weird things which trip up your edge cases.
The user may want to find the name in their own script - for example would a Greek user be looking for "Greece" or "Ελλάδα"? If a Chinese speaker wants to visit the UK, do they look in the drop-down for "英国"?
International Dialling Codes - not every country is unique - +1
is used by USA, Canada, Anguilla, Dominican Republic, and dozens more. Are there countries where there is more than one international dialling code?
OK, what if the user wants to select their language based on their country?
Do You Have A Flag? 🔗
It is one of the classic conventions that first-year students of user interface design are taught - countries do not represent language!
Some countries have multiple official languages. Some users may not speak the language of their country. Some languages are only used for official purposes, and not by the general population.
Flags mostly represent countries. There are people in Wales who would rather see Y Ddraig Goch rather than the Union Jack. And vice-versa. Flags can make people angry.
The flag of the USA last changed in 1960 - but Mauritania changed theirs in August 2017. How quickly can a browser update their list of countries?
...and yet...
I instinctively like this idea! This isn't a new question, nothing ever is, but I think it is an idea which has merit.
One of the goals of HTML is to stop web developers having to re-invent the wheel. That's why we have lots of different <input>
types - to reduce complexity.
Colour picker
Number inputs
Range selector
Some modern browsers support date input
The challenges of a country selector are...
- Keeping everyone happy and not causing major diplomatic incidents. Easy‽
- Usability. Making sure it's easy to search for the name of a country.
- Consistency. How do you indicate that this list contains historic countries?
None of these are insurmountable problems - but it's far from trivial.
And yet... I think there is a real possibility that this could work. Millions of websites already find ways to cope with the ambiguity - perhaps browsers can too?
Gaige says:
Piskvor says:
Alex says:
Dimitris Siskopoulos says:
Camilo Vitorino says:
Tanderic says:
Paul says:
Andrew Phillipo says:
Lucy Hill says:
Alan says:
Daniel Tonon says:
Tìm hiểu các phương pháp hay nhất cho biểu mẫu địa chỉ.