Difference between revisions of "Template:Flatlist/doc"

From blackwiki
Jump to navigation Jump to search
imported>Edokter
m (→‎Examples: space)
imported>Redrose64
(→‎Examples: no need for leading spaces, and if copypasted, they break)
 
(67 intermediate revisions by 29 users not shown)
Line 1: Line 1:
 +
{{redirect|Template:Inline list|a navbox listing templates used within lines of text to mark problems needing attention|Template:Inline cleanup tags}}
 
{{Documentation subpage}}
 
{{Documentation subpage}}
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
+
<!-- PLEASE ADD CATEGORIES AT THE BOTTOM OF THIS PAGE -->
 +
{{#switch:{{FULLPAGENAME}}
 +
| Template:Flatlist    = {{High-risk|117,000+}}
 +
| Template:Endflatlist = {{High-risk|80,000+}}
 +
}}
 +
This template provides a [[Web Content Accessibility Guidelines|WCAG]]/ISO-standards-compliant accessible alternative to comma- or dash- (or other single character-) separated lists, per [[WP:FLATLIST]] and [[WP:HLIST]].
 +
{{TOC limit|3}}
  
===Usage===
+
==Usage==
{{tl|Flatlist}} starts a horizontal list, such as:
+
{{tlf|flatlist}} starts a horizontal list, such as:
{{flatlist}}
+
 
 +
{{flatlist|
 
* [[cat]]
 
* [[cat]]
 
* [[dog]]
 
* [[dog]]
Line 11: Line 19:
 
* [[sheep]]
 
* [[sheep]]
 
* [[pig]]
 
* [[pig]]
{{endflatlist}}
+
}}
The bottom margin is inherited from the current container. Normally this will be 0.5em. This template can be used with or without {{tl|endflatlist}}.
+
 
 +
This template can be used with or without {{tl|endflatlist}}. For navigation boxes using {{tl|navbox}}, one can set {{para|listclass|hlist}}, and achieve the same styling without using this template. For image captions, list (i.e. asterisk) markup does not work, so consider using {{tl|hlist}} instead.
 +
 
 +
==Optional parameters==
 +
; class
 +
: Adds a CSS class to the containing div. Use <code>nowraplinks</code> to prevent links from wrapping.
 +
 
 +
; style
 +
: Adds CSS styling to the containing div. Complex styles should not be used in articles (per [[WP:Deviations]]) but may be acceptable on user, project and talk pages.
 +
: Example: {{para|<var>style</var>|<var>border:solid 1px silver; background:lightyellow</var>}}
  
For navigation boxes using {{tl|navbox}}, one can set {{para|listclass|hlist}}, and achieve the same styling without using this template.
+
; indent
 +
: Indents the list by a number of standard indents, one indent being 1.6[[Em (typography)|em]]. (Useful in an indented discussion thread.)
 +
: Example: {{para|<var>indent</var>|<var>2</var>}}
  
===Examples===
+
==Examples==
<pre><nowiki>
+
<syntaxhighlight lang="moin">
 
{{flatlist|
 
{{flatlist|
 
* [[cat]]
 
* [[cat]]
Line 26: Line 45:
 
* [[pig]]
 
* [[pig]]
 
}}
 
}}
</nowiki></pre>
+
</syntaxhighlight>
 +
 
 +
produces:
  
 
{{flatlist|
 
{{flatlist|
Line 37: Line 58:
 
}}
 
}}
  
;Alternative syntax:
+
===Alternative syntax===
<pre><nowiki>
+
<syntaxhighlight lang="moin">
{{flatlist}}
+
{{startflatlist}}
 
* [[cat]]
 
* [[cat]]
 
* [[dog]]
 
* [[dog]]
Line 47: Line 68:
 
* [[pig]]
 
* [[pig]]
 
{{endflatlist}}
 
{{endflatlist}}
</nowiki></pre>
+
</syntaxhighlight>
  
{{flatlist}}
+
produces:
 +
 
 +
{{startflatlist}}
 
* [[cat]]
 
* [[cat]]
 
* [[dog]]
 
* [[dog]]
Line 58: Line 81:
 
{{endflatlist}}
 
{{endflatlist}}
  
;Syntax for ordered lists:
+
===Syntax for ordered lists===
<pre><nowiki>
+
<syntaxhighlight lang="moin">
 
{{flatlist|
 
{{flatlist|
 
# [[first]]
 
# [[first]]
Line 68: Line 91:
 
# [[sixth]]
 
# [[sixth]]
 
}}
 
}}
</nowiki></pre>
+
</syntaxhighlight>
 +
 
 +
produces:
  
 
{{flatlist|
 
{{flatlist|
Line 79: Line 104:
 
}}
 
}}
  
===Parameters===
+
=== Using optional parameters ===
* '''class''' – adds a CSS class to the containing div. Passing <tt>hwrap</tt> allows list items to be wrapped.
+
<syntaxhighlight lang="moin">
* '''style''' – adds CSS style options. Complex styles should not be used in articles (per [[wp:deviations]]) but may be acceptable on user, project, and talk pages.
+
{{flatlist |indent=2
::Example: {{para|<var>style</var>|<var>border:solid 1px silver; background:lightyellow</var>}}
+
|style=border:solid 1px silver; background:lightyellow;
* '''indent''' – indents the list by a number of standard indents (one indent being 1.6em), particularly handy for inclusion in an indented discussion thread.
+
|class=nowraplinks |
::Example: {{para|<var>indent</var>|<var>2</var>}}
+
* [[Alpine skiing at the 1936 Winter Olympics]]
 +
* [[Alpine skiing at the 1948 Winter Olympics]]
 +
* [[Alpine skiing at the 1952 Winter Olympics]]
 +
* [[Alpine skiing at the 1956 Winter Olympics]]
 +
* [[Alpine skiing at the 1960 Winter Olympics]]
 +
* [[Alpine skiing at the 1964 Winter Olympics]]
 +
}}
 +
</syntaxhighlight>
 +
 
 +
produces:
  
===Technical details===
+
{{flatlist |indent=2 |style=border:solid 1px silver; background:lightyellow; |class=nowraplinks |
This template uses the <code>.hlist</code> CSS class defined in Common.css to generate horizontal lists. It causes ordinary html list items to be displayed inline (horizontally), where they would normally display as block elements (vertically). The class also generates the interpuncts between list items and parentheses around nested lists. Some of the CSS used is not compatible with all browsers, notably Internet Explorer 6 and 7. In these cases, JavaScript in Common.js generates the interpuncts and parentheses.
+
* [[Alpine skiing at the 1936 Winter Olympics]]
 +
* [[Alpine skiing at the 1948 Winter Olympics]]
 +
* [[Alpine skiing at the 1952 Winter Olympics]]
 +
* [[Alpine skiing at the 1956 Winter Olympics]]
 +
* [[Alpine skiing at the 1960 Winter Olympics]]
 +
* [[Alpine skiing at the 1964 Winter Olympics]]
 +
}}
  
====Bugs====
+
==Technical details==
There is one situation where the <code>.hlist</code> class will fail in one or more browsers:
+
This template uses the <code>.hlist</code> [[Cascading Style Sheets|CSS]] class defined in [[MediaWiki:Common.css]] to generate horizontal lists. It causes ordinary html list items to be displayed inline (horizontally), where they would normally display as block elements (vertically). The class also generates the [[interpunct]]s between list items and parentheses around nested lists. Some of the CSS used is not compatible with all browsers, notably Internet Explorer 6 and 7.
* When a horizontal list, built using wiki markup, is displayed on Special: pages (where it may be transcluded from MediaWiki: pages), horizontal lists will not wrap to the next line. This is due to HTML Tidy not being active on these pages. This may be fixed in the future ([[Bugzilla:39617]]). As a workaround, use HTML instead of wiki markup to build the lists.
 
  
===See also===
+
{| class="wikitable"
 +
! Wikitext
 +
! Expanded template
 +
! HTML
 +
|- style="vertical-align:top;"
 +
| <pre>
 +
{{flatlist|
 +
* cat
 +
* dog
 +
* horse
 +
* cow
 +
* sheep
 +
* pig
 +
}}
 +
</pre>
 +
| {{nowiki2|tag=pre|
 +
{{flatlist|
 +
* cat
 +
* dog
 +
* horse
 +
* cow
 +
* sheep
 +
* pig
 +
}}
 +
}}
 +
| <syntaxhighlight lang="html">
 +
<div class="hlist">
 +
<ul><li>cat</li>
 +
<li>dog</li>
 +
<li>horse</li>
 +
<li>cow</li>
 +
<li>sheep</li>
 +
<li>pig</li></ul>
 +
</div>
 +
</syntaxhighlight>
 +
|}
 +
 
 +
==Redirects==
 +
* {{tl|startflatlist}}
 
* {{tl|endflatlist}}
 
* {{tl|endflatlist}}
* {{tl|plainlist}}
+
* {{tl|flt}}
 +
 
 +
==See also==
 +
* {{tl|hlist}}
 +
* {{tl|plainlist}} and {{tl|unbulleted list}}
 +
* {{tl|bulleted list}}
 +
* {{tl|ordered list}}
 
* {{tl|multi-column numbered list}}
 
* {{tl|multi-column numbered list}}
* {{tl|nowrap begin}}/{{tl|nowrap end}}
+
* {{tl|nowrap}}
 
* {{tl|pagelist}}
 
* {{tl|pagelist}}
 
* [[WP:HLIST]]
 
* [[WP:HLIST]]
 
+
{{HTML lists}}
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
+
<includeonly>{{Sandbox other||
 +
<!-- CATEGORIES HERE, THANKS -->
 
[[Category:Typing-aid templates|Flatlist]]
 
[[Category:Typing-aid templates|Flatlist]]
[[Category:Wikipedia list formatting templates|Flatlist]]
+
[[Category:List formatting and function templates|Flatlist]]
 
}}</includeonly>
 
}}</includeonly>

Latest revision as of 09:57, 29 December 2020

This template provides a WCAG/ISO-standards-compliant accessible alternative to comma- or dash- (or other single character-) separated lists, per WP:FLATLIST and WP:HLIST.

Usage

{{flatlist}} starts a horizontal list, such as:

This template can be used with or without {{endflatlist}}. For navigation boxes using {{navbox}}, one can set |listclass=hlist, and achieve the same styling without using this template. For image captions, list (i.e. asterisk) markup does not work, so consider using {{hlist}} instead.

Optional parameters

class
Adds a CSS class to the containing div. Use nowraplinks to prevent links from wrapping.
style
Adds CSS styling to the containing div. Complex styles should not be used in articles (per WP:Deviations) but may be acceptable on user, project and talk pages.
Example: |style=border:solid 1px silver; background:lightyellow
indent
Indents the list by a number of standard indents, one indent being 1.6em. (Useful in an indented discussion thread.)
Example: |indent=2

Examples

{{flatlist|
* [[cat]]
* [[dog]]
* [[horse]]
* [[cow]]
* [[sheep]]
* [[pig]]
}}

produces:

Alternative syntax

{{startflatlist}}
* [[cat]]
* [[dog]]
* [[horse]]
* [[cow]]
* [[sheep]]
* [[pig]]
{{endflatlist}}

produces:

Template:Startflatlist

Syntax for ordered lists

{{flatlist|
# [[first]]
# [[second]]
# [[third]]
# [[fourth]]
# [[fifth]]
# [[sixth]]
}}

produces:

Using optional parameters

{{flatlist |indent=2 
|style=border:solid 1px silver; background:lightyellow; 
|class=nowraplinks |
* [[Alpine skiing at the 1936 Winter Olympics]]
* [[Alpine skiing at the 1948 Winter Olympics]]
* [[Alpine skiing at the 1952 Winter Olympics]]
* [[Alpine skiing at the 1956 Winter Olympics]]
* [[Alpine skiing at the 1960 Winter Olympics]]
* [[Alpine skiing at the 1964 Winter Olympics]]
}}

produces:

Technical details

This template uses the .hlist CSS class defined in MediaWiki:Common.css to generate horizontal lists. It causes ordinary html list items to be displayed inline (horizontally), where they would normally display as block elements (vertically). The class also generates the interpuncts between list items and parentheses around nested lists. Some of the CSS used is not compatible with all browsers, notably Internet Explorer 6 and 7.

Wikitext Expanded template HTML
{{flatlist|
* cat
* dog
* horse
* cow
* sheep
* pig
}}
Template:Nowiki2
<div class="hlist">
<ul><li>cat</li>
<li>dog</li>
<li>horse</li>
<li>cow</li>
<li>sheep</li>
<li>pig</li></ul>
</div>

Redirects

See also