World map SVG with country codes

One path per country, ids you can target in CSS or code. See the file size before you download.

175 paths · 123 KB

Built for code and design tools

ISO ids

Each path's id is its ISO 3166 code (alpha-3, alpha-2 or numeric), with the name in data-name and the continent as a class.

Size you control

Fewer decimals in coordinates mean a smaller file. 1 decimal is invisible at screen size.

GeoJSON too

The same countries in longitude and latitude, with ISO codes and continent in properties.

Style it with CSS, read names with JavaScript

The file has one path per country inside a group with the id regions. Each path has the ISO code as its id, the continent as a class and the name in data-name.

/* ids are ISO 3166-1 alpha-3 codes */
#FRA, #DEU, #ITA { fill: #2f7fbf; }
.region.af { fill: #f2d27a; }      /* every African country */
#regions path:hover { fill: #d63a2f; }

Names for a hover label come from data-name:

const svg = document.querySelector('svg');
svg.addEventListener('mouseover', (e) => {
  const name = e.target.dataset.name;  // from data-name
  if (name) svg.querySelector('title').textContent = name;
});

Questions

Can I use it commercially?

Yes. The borders are Natural Earth, public domain; no credit is required, though it is welcome.

Why is 1:10m so large?

It holds every small island and a detailed coast: several megabytes. Use 1:110m for icons and dashboards, 1:50m for print.

Does the SVG have country names on it?

No visible text, so it works as a blank map. Each name is in the data-name attribute, ready for tooltips or labels in code.

Which code set are the ids?

ISO 3166-1: alpha-3 by default (FRA), or alpha-2 (FR) or the numeric code (n250, with a letter in front because an id cannot start with a digit). Places without an ISO code get a slug of their name.