Template:Strikethrough
Example text
This template simplifies inline formatting of text to appear styled with a horizontal line superimposed on it through the mid-line, typically to indicate that it has been deleted/retracted, or is otherwise no longer applicable.
Usage
[edit]This template accepts only one unnamed/positional parameter, whose value is the text to be styled with a line through it.
Limitations
[edit]If the text to be styled contains any equality symbols (=, Unicode character U+0003D), it will prevent this template from functioning correctly. In such cases, two simple workarounds are available.
- Use an explicitly named
1parameter instead of an unnamed/positional one. This takes the form|1=styled text, to which the content may be assigned as-is. - Any equality symbols in the content must be escaped (replaced) as either:
- The MediaWiki magic word
{{=}}, or - An HTML entity corresponding to the equality symbol, those being:
=– named entity,=– numeric decimal entity, or=– numeric hexadecimal entity.
- The MediaWiki magic word
Accessibility
[edit]Of note, a consensus has formed among users and developers of accessibility tools such as screen readers (for users with visual impairments) to ignore the semantics used by this template (see § Theory of operation below) to style content, though a few applications do provide an option to "Report font attributes" but only as an opt-in behavior. If editors have reason to expect that being unaware that users of such tools would be disadvantaged if left unaware that content appears visually as struck-through, they are strongly encouraged not to rely solely on this template.
Current best practices regarding semantics such as these typically dictate that another inline element (typically a pair of <span> tags) is added immediately preceding the struck-through content with certain attributes (e.g., id="unique_id" role="note" style="display: hidden;" that contain a brief context clue for the strikethrough styling, e.g., "No longer valid" or "Deprecated since 2024". The element containing the styled text (for this template, the semantic HTML <s> tags) would then take on the additional attribute aria-describedby="unique_id", instructing accessibility tools to read the preceding element with the added context before reading the styled text. Best of all, none of it has any impact at all on the experience of ordinary readers (thanks to the extra element being marked display: hidden; and aria-* attributes being acted upon only by assistive tools).
Examples
[edit]Basic
[edit]Example: Basic use (single unnamed/positional parameter)
{{Strikethrough|struckthrough text}} ⇒ struckthrough text
Named parameter
[edit]Example: Using the named parameter |1= to style content containing equality symbols (Note: if nesting another template inside this one, as seen here, you must switch to named |1= parameters for them all)
{{Strikethrough|1='''{{Serif|1=x × y = 0}}'''}} ⇒ x × y = 0
Character escaping
[edit]Example: Using the magic word {{=}} to escape equality symbols in styled content
{{Strikethrough|'''{{Serif|x × y {{=}} 0}}'''}} ⇒ x × y = 0
Example: Using the HTML entity = to escape equality symbols in styled content
{{Strikethrough|'''{{Serif|x × y = 0}}'''}} ⇒ x × y = 0
Theory of operation
[edit]This template wraps the content supplied to it in HTML <s>...</s> tags (an inline element), which all modern web browser display engines render by applying the CSS style declaration text-decoration-line: line-through; to their contents.
TemplateData
[edit]Strikethrough
Style inline content with a horizontal line through the middle of it by wrapping it in HTML <s> tags
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| Styled content | 1 | The inline content to be styled with a horizontal line through the middle of it
| Line | required |
See also
[edit]- {{Bar}} – struck-through white space
- {{Strikethrough block}} – for strikethrough styling of entire blocks of content