Country flags are often used for picking a language, or for content that goes with a certain country. The J1 Theme comes with country flags built in. You can use them to make language pickers or country labels easier to spot for your visitors.
The J1 Theme uses the CSS file from the Flag Icons project by Panayiotis Lipiridis. Flag Icons is a set of country flag pictures saved in the SVG format. SVG pictures can be made bigger or smaller without losing any sharpness.
15-30 Minutes to read
HTML Markup
There is no official HTML markup for CSS font icons, but two ways are
commonly used. You can use either one with block items like the anchor
tag <a> or with span items <span>. It is up to you which to use for
your font icons.
<span class="flag-icon flag-icon-gr rectangle size-md" role="img" aria-label="flag-gr"></span> (1)
<i class="flag-icon flag-icon-gr rectangle size-md"></i> (1) (2)
| 1 | Both forms are consistent with the HTML5 specification |
| 2 | It’s short and the i tag <i> may associated for an icon
(semantic meaning) |
|
The i tag |
Asciidoc Markup
If your page is written in Asciidoc, there is an even easier way: use the Asciidoc markups below.
pass:[<i class="flag-icon flag-icon-<name> <style> <size> <modifier>"></i>] (1)
flag:country[style, size, modifier] (2)
| 1 | Markup using a pass block |
| 2 | Markup using the Asciidoc (inline) extension flag |
Styles
Country flag icons come in two styles: rectangle rectangle and
square squared. The default is rectangle (a 4:3 shape). For a more
compact look, you can use the square style (a 1:1 shape).
flag:de[rectangle, md] Germany, rectangle style +
flag:de[squared, md] Germany, squared style
-
Germany, rectangle style
-
Germany, squared style
Sizes
You can change how big a flag icon is to make it stand out more, or to
fit it in a tight spot. Just use the optional size setting.
|
The size of a flag is set relative to the base font size. The base
font size today is 16 pixels ( |
See below for what sizes you can use.
Relative Sizes
To work well with Bootstrap and to adjust to any screen, you can set the
icon size using the Bootstrap screen-size shortcuts: from xs to xl —
xs, sm, md, lg, xl.
| Size | Style | Markup | Render |
|---|---|---|---|
|
|
rectangle |
Germany
|
|
|
|
rectangle |
Germany
|
|
|
|
rectangle |
Belgium
|
|
|
|
rectangle |
Denmark
|
|
|
|
rectangle |
Spain
|
|
Proportional Sizes
You can also set the size relative to the base size, from 1x to 10x
(1x to 10x). See the examples in the table below.
| Size | Style | Markup | Render |
|---|---|---|---|
|
|
rectangle |
Germany
|
|
|
|
rectangle |
Denmark
|
|
|
|
rectangle |
Spain
|
|
Modifiers
For more layout control, you can add extra CSS styles called modifiers to your flag icons. Here is an example:
flag:de[rectangle, md, ml-3 mr-3 mb-2] Germany, rectangle style +
flag:de[squared, md, ml-3 mr-3 mb-2] Germany, square style
Germany, rectangle style
Germany, square style
Flags Overview
Find all flags available, listed in A-Z order.