Skip to the content

Hata旗

Load a native country or region flag, choose supported framing and keep each drawing’s source, author and licence.

Hata (旗) is Japanese for a flag. About the name

Contents

How-to

Plain HTML and CDNs

Put a flag on a plain page with one script tag from jsDelivr or unpkg.

A page needs no build step. The element/define entry registers the <hata-flag> tag; a script tag from a CDN loads it, and the tag draws the flag named by its code. Each flag is a file of its own, fetched when the tag asks for it.

jsDelivr

jsDelivr serves the package's files as they are, so the address is the built file.

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Hata from jsDelivr</title>
    <script type="module" src="https://cdn.jsdelivr.net/npm/@johnmorrisdotca/hata@1/dist/element-define.js"></script>
  </head>
  <body>
    <p>Tokyo: <hata-flag code="JP-13" label="Tokyo"></hata-flag></p>
  </body>
</html>

unpkg

unpkg serves the package's own files too; ?module makes it rewrite the imports inside them for the browser.

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Hata from unpkg</title>
    <script type="module" src="https://unpkg.com/@johnmorrisdotca/hata@1/dist/element-define.js?module"></script>
  </head>
  <body>
    <p>Tokyo: <hata-flag code="JP-13" label="Tokyo"></hata-flag></p>
  </body>
</html>

Notes

  • Use <script type="module">. A classic script cannot import.
  • Pin a major version in the address (@johnmorrisdotca/hata@1) so the page stays as it is.
  • The attributes are in the flag element and its events. If nothing appears, see troubleshooting.

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/hata 1.31.0.