Changes

Jump to navigation Jump to search
{{Documentation subpage}}
{{Uses TemplateStyles|Template:If mobile/styles.css}}
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
{{info|Note that {{tlx|If mobile}} only works outside of the Template: namespace.}}
This template detects whether it is being used on the mobile version of Wikipedia (en.m.wikipedia.org), and displays different content accordingly.

==Rationale==
Some features work differently on the mobile website, such as slideshow galleries appearing as ordinary galleries. This templates 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.
cghvhbkm,

== Usage ==
<code>{{braces|If mobile{{!}}''content for mobile website''{{!}}''content for desktop website''}}</code>

By default, {{tag|span}} tags are used to wrap the specified content. A different tag may be specified using {{para|tag}}
:E.g. {{para|tag|div}} can be used if the content contains block-level elements.

==Example==
===Normal usage===
<code><nowiki>{{If mobile|A mobile user you are!|You are looking at the desktop site}}</nowiki></code>
* [https://en.wikipedia.org/w/index.php?title=Wikipedia:Sandbox&oldid=857234029 view on desktop website]
* [https://en.m.wikipedia.org/w/index.php?title=Wikipedia:Sandbox&oldid=857234029 view on mobile website]

===Within the Template: namespace===
Note that the behaviour is different when within the Template: namespace! (e.g. on this documentation page)

<code><nowiki>You are currently viewing the {{If mobile|mobile website|desktop website}}.</nowiki></code>
: You are currently viewing the {{If mobile|mobile website|desktop website}}.
* [https://en.wikipedia.org/w/index.php?title=Template:If_mobile/doc View on desktop website]
* [https://en.m.wikipedia.org/w/index.php?title=Template:If_mobile/doc View on mobile website]

{{Namespace and pagename-detecting templates|state=collapsed}}

<includeonly>{{sandbox other||
<!-- Categories below this line, please; interwikis at Wikidata -->
[[Category:Wikipedia templates that change text based on client state]]
[[Category:Boolean, register, and condition testing templates]]
}}</includeonly>
Anonymous user

Navigation menu