No image, no CSS, you can show country flags on your web pages with unicode only. See Regional Indicator Symbol for details. And find valid country codes here, ISO 3166-1 alpha-2.
Add this line to your application's Gemfile:
gem 'unicode_country_flags'And then execute:
$ bundle
Or install it yourself as:
$ gem install unicode_country_flags
Get the raw code:
UnicodeCountryFlags::CountryFlags.flag_of('cn') #=> "🇨🇳"Or use the helper, unicode_country_flag_of, in view code:
<% %w{ US GB AU CN JP }.each do |code| -%>
<span><%= unicode_country_flag_of(code) %> <%= code %></span>
<% end %>🇺🇸 US 🇬🇧 GB 🇦🇺 AU 🇨🇳 CN 🇯🇵 JP
Bug reports and pull requests are welcome on GitHub at https://github.com/YanhaoYang/unicode_country_flags.