Template:Text-indent/s

Template documentation


This template adds indentation to text using the CSS text-indent property. This property controls the indentation of the first line of a paragraph of text. It can be specified with any valid CSS unit, but em is the preferred unit. The indentation can be 0 to disable an inherited indent, or negative to achieve various special effects such as hanging indents (but use {{hanging indent}} for that). The default value is 2em.

Note that this template should not be used to attempt to replicate the printing style where the first line of every new paragraph is indented.


Usage

edit

The primary calling convention for this template is the block-based one:

{{ti/s|CSS unit}} … text … {{ti/e}}


For a single shorter run of text containing no characters that are significant in wikicode (equals signs in particular), you can also use the inline calling convention:

{{ti|CSS unit|text}}


For most use cases though, the block calling convention is strongly recommended as it is the most flexible and creates the fewest surprising edge cases and weird behaviour..

Arguments

edit

This template uses positional (unnamed) parameters. If only one parameter is provided it is assumed to be a CSS length value and is passed directly into the style attribute for the container (so make sure you provide a valid value here!). If you are using the inline calling convention you can also provide the text the template should apply to in the second unnamed parameter. In either case you can leave the indent amount empty and the template will default to 2em.

  {{ti}} {{ti/s}}
1= length length
2= text

Examples

edit

Example: basic block based calling convention

{{ti/s}}{{lorem ipsum}}{{ti/e}}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


Example: with a custom length

{{ti/s|5em}}{{lorem ipsum}}{{ti/e}}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


Example: overriding an inherited text-indent

{{ti/s|5em}}
{{lorem ipsum}}
{{ti/s|0}}{{lorem ipsum}}{{ti/e}}
{{lorem ipsum}}
{{ti/e}}

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


Example: hanging indent

{{left margin|2em}}
{{ti/s|-2em}}{{lorem ipsum}}{{ti/e}}
{{div end}}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


Basic use

edit
{{text-indent|CSS unit|text}}

For a single shorter run of text containing no characters that are significant in wikicode (equals signs in particular), you can use the inline calling convention: the amount of indentation is given in the first parameter, and the text to which it is to be applied in the second. For most use cases though, the block calling convention is strongly recommended.

Example

Lorem ipsum dolor sit amet, consectetuer adipiscing elit.

Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.

Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.


Cui dōnō lepidum novum libellum āridā modo pūmice expolītum

Please note that the last paragraph is not indented, since there are two new lines before it. This makes MediaWiki insert a <br /> before it which "steals" the indentation.

See also

edit