Wikipedia:HiddenStructure
- On hiding text, see Help:Hidden text
As of December 29, 2006, this technique is disabled on this wiki. The class hiddenStructure still exists in the CSS, but now outlines the text in green instead of hiding the text. This is to find any remaining instances of hiddenStructure in templates. Note that this only disables use of the CSS class hiddenStructure. It does not prevent use of similar tags like display: none or visibility: hidden. These still cause accessibility problems, and should be used with caution (see "other uses" section below). |
This form of syntax is highly frowned upon, and it should not be used. Due to browsers that don't support CSS, and other devices such as screen readers, using this syntax results in vastly inferior pages for many users. The below is documented for informational purposes only. |
This page has been closed down by community consensus, and is retained only for historical reference. If you wish to restart discussion on the status of this page, seek community input at a forum such as the village pump. |
By using Cascading Style Sheets (CSS), it is possible to hide text in templates from popular web browsers, dependent upon the emptiness of a template parameter. Please, don't use it. This page documents a specific highly controversial method to achieve that.
Brion VIBBER [1], lead developer of MediaWiki, describes some of the problems with hiddenStructure.
...it's using a CSS hack to hide structure elements, which can fail for text browsers, plaintext renderings of articles, and any HTML display of the article that doesn't use the stylesheet on this site. This harms both the primary site's accessibility and offsite reuse of material.
Graham87 [2], a blind Wikipedian, discusses screen reading software and the limitations therein, and also states that he doesn't believe we should use CSS hacks.
...I would strongly recommend that the css hacks not be used because there will be a sizable number of people using older screen readers, and they may not be able to upgrade.
How it works
[edit]This method relies on the existence of a CSS class "hiddenStructure". For the en: wiki this is defined in MediaWiki:Common.css as (revision as of 20:50, January 17, 2006):
/* hiddenStructure from Monobook - allows selective hiding of markup in templates */
.hiddenStructure {
display: none;
speak: none;
}
Any text that is contained within the HTML construct <div class="hiddenStructure">text to hide</div>
is hidden. The class can also be applied to any XHTML element, such as <span> and wikitable rows (|-).
This function is then combined with the parameter default function to achieve selective hiding of text depending on the emptiness of the template parameter. Here is an example of a simple table, which could be part of a template. if the "parameter" is left blank, class{{{parameter|}}}
resolves to simply class
, completing the CSS call as above. For any value of "parameter", the style becomes meaningless and is stripped by the MediaWiki software, making the table row visible, as well as the data.
{|
|- class{{{parameter|}}}="hiddenStructure"
! Header
| {{{parameter|}}}
|}
Caveats
[edit]This method does not hide text from any non-CSS browsers (including text-only browsers, like Lynx), nor from users of many types of screen readers and other accessibility software. Pages relying on this method also fail to display properly when copied to other sites which have not been configured to use the 'hiddenStructure' class, including foreign language Wikipedias and possibly some Wikipedia mirrors. Therefore, it is important that the template be readable and make sense to someone using such a browser. If a page depends on this technique to make sense, then it will break a WAI priority 1 accessibility checkpoint. Some common pitfalls involve overuse of this by marking every row in an Infobox as optional, or using this method to hide punctuation around an optional parameter.
- Using CSS to hide unintentionally-created document structure is considered poor web authoring practice.
- This approach will transmit redundant information to the clients
- In some cases, this approach includes raw wikitext, which is meaningless in the context of an article (e.g. template:Infobox President)
- This approach creates a slightly different version of an article's content in a visual browser than for other browsers and search engines.
- If the two versions of an article differ in meaning, then the page fails all three levels of accessibility validation.
Problems
[edit]The problem with using hiddenStructure is that it hides rows in a non-standard way. Whereas other websites hide data by simply not sending it out from the server[1], hiddenStructure defers this hiding process to the client. Because of this, some non-CSS aware or compliant browsers incorrectly render pages using this hack (see pictures at right).
Some pages minimize the damage by only displaying the parameter if it's actually non-blank (using the syntax {{{parameter|}}}
). In this way only the row is displayed, not the ugly {{{parameter}}} parameter name. Of course in templates with large numbers of conditional rows, this still results in unnecessary data being displayed to non-CSS compliant browsers.
Because of these problems many articles render poorly for the disabled. In the worst case, a number of Wiki-markup parameters are displayed/read to the reader. In the best case, a number of rows are displayed/read which are empty.
For these reasons, hiddenStructure should not be used.
Footnote:
Solutions
[edit]Solutions, in order of preference, are.
- Use ParserFunctions
- Advantage: less server load and less likely to break than other methods.
- Use Weeble code (such as {{row}}).
- Advantage: Can avoid meta-templates altogether.
- Problem: Requires that a blank parameter (usually
if=
) be passed. Also, if and when conditionals are implemented in MediaWiki, it may be more difficult to find and replace templates utilizing this method. Finally, templates that use Weeble are generally the ugliest as far as the code is concerned.
- Limit or eliminate conditional rows.
- Advantage: Avoids the issue of conditional row displays.
- Problem: Avoids the issue of conditional row displays.
Other possible solutions, which are ill-advised, include:
- Breaking apart a single template into various multiple other templates, with each handling different combinations of parameters.
- Problem: This is a maintenance nightmare, and goes against the purpose of templates (centralizing maintenance to one place).
Other uses
[edit]One of several accepted uses of CSS display: none
is to hide kludges inserted only for legacy browsers from modern browsers. A typical example is reset-buttons; no modern browser needs this, as users can clear textareas locally. Legacy browsers don't offer this feature and depend on a reset-button. Users clicking reset unintentionally would lose their modifications in the form. A hidden reset-button only visible with legacy browsers avoids this problem.
Other examples are media specific applications: Emoticons (smileys) as ASCII art are arguably pointless for speech browsers, it's possible to hide them there, maybe offering a WAV. Sometimes copyright info can be restricted to the printed output. Info normally only available for visual browsers with a mouse could be additionally displayed as normal text hidden from most output media except from text, print, and speech. A similar concept is the <noscript>
element.
Known uses
[edit]- This is an incomplete list of known uses arguably considered to be harmless, please add what you find:
Template:Hide(edit talk links history)- probably not harmless
See also
[edit]- Template:Infobox(edit talk links history) - a "model" infobox template which demonstrated this method, later removed.
- Template:Infobox Conditionals(edit talk links history) - same with conditionals.
- Wikipedia:Qif conditionals - explanation of the #if: conditional technique.
- Wikipedia:Accessibility - several proposals addressing WAI issues.
- Wikipedia:Historic debates - features also WP:HIDE.
- m:ParserFunctions - a replacement for {{qif}} and hiddenStructure.
- m:Help:Array - explains also older methods like "weeble".