How to use "For" tags

Revision Information
  • Revision id: 219837
  • Created:
  • Creator: Mozinet
  • Comment: left side panel, Firefox OS-related fragment, four weeks cycle
  • Reviewed: Yes
  • Reviewed:
  • Reviewed by: AliceWyman
  • Is approved? Yes
  • Is current revision? No
  • Ready for localization: Yes
  • Readied for localization:
  • Readied for localization by: AliceWyman
Revision Source
Revision Content

One of the great features of our Knowledge Base is the ability to show instructions customized for operating systems (Windows, Mac, etc.) and Firefox versions. We can say, for example, that a certain section of a help article is "for" Windows users and Mac and Linux users won't see it. The feature is designed to work invisibly. When someone opens a help article, we'll automatically detect what operating system and version of Firefox they are using and show the appropriate instructions. This article goes over the details of how to use {for} in Knowledge Base articles.

Localizers: when localizing articles with {for} and {/for} elements in the content, do not translate anything inside the { and } brackets! Keep them the same way they look in the original text. This is important to have the element function properly.

How to switch instructions to different operating systems or Firefox versions

In order to follow the example in this article, you'll have to switch the article selector to different operating systems and Firefox versions. It's located in the right panel of the article, under Editing Tools.

VersionSelector-2018

Basic syntax and behavior

Operating Systems

Here is the syntax to show an image for Windows 7/Vista:

{for win7}[[Image:vista.jpg]]{/for}
  • Change the selector to Windows 7/Vista to see the image:
vista.jpg
  • If you change the selector to Windows XP, Windows 8, Windows 10, Mac or Linux, the image above won't be shown because it's not "for" them.

Although the Windows selector doesn't exist, you can write instructions that apply to all Windows versions:

{for win}[[Image:Windows Logo]]{/for}
  • Change the selector to Windows XP, Windows 7/Vista, Windows 8 or Windows 10 to see the image:
Windows Logo
  • If you change the selector to Mac or Linux, the image above won't be shown because it's not "for" them.

Firefox versions

Here is the syntax to show something for Firefox 63 and above:

{for fx63}[[Image:Firefox Quantum Logo]]{/for}
  • Change the selector to Firefox 63 or higher to see the image:
Firefox Quantum Logo
  • If you change the selector to Firefox 62 or lower the message above will disappear because it's not "for" those versions.

Show instructions for only one version of Firefox

To show instructions only for Firefox 63, use the "=" operator:

{for =fx63}[[Image:Firefox Quantum Logo]]{/for}
  • Now the image only shows when you change the selector to Firefox 63:
Firefox Quantum Logo

Combining operating systems & Firefox versions

You can specify an operating system and a Firefox version by separating them with a comma:

{for win,fx63}[[Image:Windows Logo]][[Image:Quantum Logo]]{/for}
  • Change the selector to Windows and Firefox 63 or higher to see images:
Windows LogoFirefox Quantum Logo

A more complex situation with an implied "for" can be written like this:

{for mac, winxp, win7, =fx61, fx63}[[Image:Windows Logo]][[Image:macos.jpg]][[Image:Firefox Quantum Logo]]{/for}
  • Change the selector to Mac or Windows XP or Windows 7/Vista and Firefox 61 or Firefox 63 and above to see images:
Windows Logomacos.jpgFirefox Quantum Logo

Negating conditions

You can negate a condition by preceding it with the word not. A negated condition is true if and only if the condition is false. For example, the condition

not fx63

is true if the Firefox version is less than 63.

When the contents are shown

Formally, the markup between {for} and {/for} will be shown if both of these conditions are met:

  • The {for} has no operating system (OS) condition, or it has at least one OS condition that is true regarding the OS the user is running (or has manually selected).
  • The {for} has no Firefox version condition, or it has at least one Firefox version condition that is true regarding the Firefox version the user is running (or has manually selected).

Otherwise, the contents of the {for}…{/for} are not shown.

A few other things to note:

  • Spaces after the commas are optional.
  • {for} and other wiki markup doesn't work in article search summaries.
  • Headings which are hidden by {for} blocks do not appear in the page's table of contents. If the user causes them to show by manually selecting the right OS/browser combination, the table of contents entries instantly appear.

Operating system and product abbreviations

These are the operating system and product abbreviations available for use with {for}:

  • win (Windows)
  • winxp (Windows XP/2000/Server 2003)
  • win7 (Windows 7/Vista/Server 2008)
  • win8 (Windows 8/8.1/Server 2012)
  • win10 (Windows 10)
  • mac (macOS)
  • linux (Linux)
  • fxN where N = the Firefox version, i.e. fx62, fx63, fx64, etc.
  • mN where N = the Firefox for Android version, i.e. m22, m23, m24, etc.
  • tbN where N = the Thunderbird version, i.e. tb24, tb31, tb38, etc.

You have to use fxN in Firefox support articles, mN in Firefox for Android support articles and tbN in Thunderbird support articles.

Inline and block-level contexts

{for} can be used in both inline and block-level contexts (in the HTML sense). The inline form takes effect when working within a line of text:

This is {for win}inline use{/for}.

The block form is used to wrap entire paragraphs, ordered lists, headings, and so on. The only caveat is that, when using the block form, the {for} and {/for} should each be on a line by itself. Otherwise, it might be considered part of a neighboring paragraph and produce surprising results.

{for win}
This is block-level.
*One
*Two
{/for}

Best practices for using {for} in articles

When writing instructions for different operating systems, it's best to write complete sentences and paragraphs for each OS/Firefox version even if it means duplicating things. This makes the article easier to understand, maintain and localize. When it comes time, for example, to remove specific instructions for Firefox 12 and below, those sections can just be deleted rather than trying to excise them from a larger section.

  • The wrong way to use {for}:
#{for not fx63}{for win,linux}At the top of the Firefox window{/for}{for mac}On the menu bar{/for}, click on the {/for}{for fx63}Click the menu button, go over to the {menu History} menu{/for}{for winxp,mac,linux,not fx63}{menu Tools} menu{/for}{for win7,win8,not fx63}{menu Firefox} menu, go over to the {menu History} menu{/for} and select {menu Clear Recent History…}
  • The right way to use {for}:
{for not fx63}
#{for win7,win8}At the top of the Firefox window, click on the {menu Firefox} menu, go over to the {menu History} menu and select {menu Clear Recent History…}{/for}{for mac}On the menu bar, click on the {menu Tools} menu and select {menu Clear Recent History…}{/for}{for winxp,linux}At the top of the Firefox window, click on the {menu Tools} menu and select {menu Clear Recent History…}{/for}
{/for}
{for fx63}
#Click the menu button, go over to the {menu History} menu and select {menu Clear Recent History…}.
{/for}
  • In the following example, we treat Firefox 60 and below, Firefox 61/62, and Firefox 63 and above as three different sets of instructions. That's often the case, but more and more as we change Firefox every four weeks we'll see more changes in later versions. They'll look like this:
{for not fx61}
#The old instructions.
{/for}
{for =fx61,=fx62}
#The new instructions.
{/for}
{for fx63}
#The NEW new instructions.
{/for}