Wikipedia:Don't use hiddenStructure

This is an old revision of this page, as edited by Locke Cole (talk | contribs) at 01:55, 24 March 2006 (moved User:Locke Cole/Don't use hiddenStructure to Wikipedia:Don't use hiddenStructure: moving to Wikipedia namespace). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Recently a cascading style sheets (CSS) "hack" known more generally as "hiddenStructure" has seen widespread use on Wikipedia. This hack makes it possible to conditionally hide rows of data in tables dependent upon whether or not certain parameters are passed (or are/aren't empty/blank).

By using hiddenStructure in templates, editors are creating deficient templates that may output invalid or poor HTML. Further, CSS (normally a way of applying styles such as fonts, colors, and so forth) was never really intended to be used in this manner, and doing so violates at least one WAI accessibility guideline.

Problems

 
USS Monitor using CSS hacks
 
USS Monitor using meta-templates
 
Blue Whale using CSS hacks
 
Blue Whale using meta-templates

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.

Solutions

Solutions, in order of preference, are.

  • Use meta-templates such as {{qif}} to conditionally display data.
    • Advantage: When conditional syntax is brought into MediaWiki, using Special:Whatlinkshere should make it easy to identify templates which need to be upgraded.
    • Problem: Can clutter up templates with HTML, but not as bad as Weeble usually.
  • 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.

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).

Notes

  1. ^ Most websites use PHP or ASP to conditionally send data from the server. More advanced designs cache results so PHP/ASP scripts are only executed once for each possible outcome.

Quotes

  • 2006-01-21 20:28:08 — Here Brion VIBBER, 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.Brion VIBBER (talk · contribs)
  • 2006-01-23 05:08:05 — Here Graham87, 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.Graham87 (talk · contribs)

See also