/
| This is the template sandbox page for Template:If mobile (diff). See also the companion subpage for test cases. |
| This template is used in system messages, and on approximately 2,100 pages. Changes to it can cause immediate changes to the Wikipedia user interface. To avoid major disruption, any changes should be tested in the template's /sandbox or /testcases subpages, or in your own user subpage. The tested changes can be added to this page in a single edit. Please discuss changes on the talk page before implementing them. |
| This template uses TemplateStyles: |
{{If mobile}} does not work in the Template: namespace. |
| As a general rule, it is recommended to avoid using this template. For mobile compatibility, see the recommendations for mobile friendly articles, and use TemplateStyles and CSS. |
This template detects whether it is being used on the mobile version of Wikipedia (i.e., en
Rationale
editSome features work differently on the mobile website, such as slideshow galleries appearing as ordinary galleries. This template allows better presentation of such content, by e.g. having a "Slideshow" heading when a slideshow is shown, and a "Gallery" heading when a regular gallery is shown.
Usage
edit{{If mobile|content for mobile website|content for desktop website}}
By default, <span>...</span> tags are used to wrap the specified content. A different tag may be specified using |tag=
- E.g.
|tag=divcan be used if the content contains block-level elements.
Example
editNormal usage
edit{{If mobile|A mobile user you are!|You are looking at the desktop site}}
Within the Template: namespace
editNote that the behaviour is different when within the Template: namespace! (e.g. on this documentation page)
You are currently viewing the {{If mobile|mobile website|desktop website}}.
- You are currently viewing the desktop websitemobile website.
Sandbox version
edit{{If mobile/sandbox|A mobile user you are!|You are looking at the desktop site}}