This example page shows how to use the Signal Flags JavaScript loader to include many flag images on a web page without downloading them individually. For more information and signal flag resources see the Signal Flags website.
Include the Signal Flags Loader script anywhere on the page (in the
<head>
is best if you use async
as
in the example below).
<script async src="https://cdn.jsdelivr.net/npm/signal-flags@2"></script>
There are no other dependencies and we have not found any conflicts but note that the code is unlikely to work in any version of Internet Explorer other than IE 11.
Insert a small image like this
in any text by writing
<img alt="Signal flag [name]">
, replacing
[name]
with the abbreviated name of the flag. Inline
images are sized to fit their context so they are…
You can also set a width and/or height for the image e.g.
<img alt="Signal flag AP" height="10">
<img alt="Signal flag n1" width="120">
.
The list below shows the abbreviated flag names we use:
a
, b
, c
, … x
, y
, and z
;
n0
,
n1
,
n2
,
… n7
, n8
, and
n9
;
ap
;
s1
, 2nd
s2
,
and 3rd s3
;
black
,
blue
,
green
,
red
,
yellow
,
greenwhite
, and
blackwhite
.
For more control over the size and position of an image, wrap it in
a containing <div>
and set the style
attribute like this:
<img alt="Signal flag A" style="display: block;" />
By default a block element will take up the whole width of the page
so for smaller sizes you can either use a CSS layout framework like
Bootstrap
or set the width
in CSS yourself. Pennants (numerals
and the Answering Pennant) and substitutes look good at 1.25×
the width of rectangular flags.
a
z
blackwhite
greenwhite
n1
n1
ap
s1
If you want full control over the display of a flag you can get the
svg
markup by calling the get(flag, options) method on
a SignalFlags object: see the documentation for more information.