' TemplateStyles' allow custom CSS pages to style content without an interface administrator having to edit sitewide CSS. TemplateStyles make it more convenie…
| This page is a guideline on the Simple English Wikipedia. Many editors agree with the ideas on this page. It is a good idea to follow it, but it is not policy. You can change the page as needed, but please use the talk page to make sure that other editors agree with any big changes. |
| ADVANCED EDITORS ONLY This document is very technical and contains complex and technical language. Do not use this or attempt to do anything if you have little to no experience in programming and how templates work on Wikipedia. This is being used to update the templates to a certain format. If you have any questions, please post on Simple Talk and clarify the issue. You will be responsible for breaking anything, so test all changes and preview everything before committing it. If you break anything by introducing articles, you can be blocked for disruptive editing as these templates are across our entire platform. |
' TemplateStyles' allow custom CSS pages to style content without an interface administrator having to edit sitewide CSS. TemplateStyles make it more convenient for editors to style templates. For example, those for which the sitewide CSS for the mobile skin or another skin (e.g., Timeless) currently negatively affects the display of the template.
Despite the name, templateStyles works on all types of pages, not just templates.
!important in TemplateStyles is exceptionally difficult to override because of the loading order of styles (personal CSS then TemplateStyles)./* {{pp-template}} */ to any protected CSS pages to ensure that they display the appropriate lock icon. Protected templates using CSS pages that lack the lock icon will be categorized in Category:Templates using TemplateStyles without padlocks.Note that the Manual of Style, including the Accessibility guidelines, still applies.
<templatestyles src="myTemplate/styles.css" /> (you don't need to specify the Template: namespace). It's probably best at the top so that it is obvious and to avoid a flash of unstyled content, but it will need to be on its own line if the template begins with wiki markup that has to start on a new line (e.g. wiki-table).{{Uses TemplateStyles}} to the template's documentation to show which TemplateStyles stylesheets it uses.{{Uses TemplateStyles}} is placed on a template's documentation, it adds the template to Category:Templates using TemplateStyles. If the TemplateStyles stylesheet has a lower protection level, the template will be tracked in Category:Templates using TemplateStyles with a different protection level (3 pages).Because of how TemplateStyles is implemented, overriding TemplateStyles in your personal CSS requires a little more effort than normal. The rules on a specific TemplateStyles sheet are not the full CSS rules, nor can you match the selectors to override them.
.mw-parser-output, so to override a rule in a TemplateStyles sheet that looks like .documentation {}, a naive override in your personal CSS file would need to look like .mw-parser-output .documentation {}..mw-parser-output div.documentation {}. Another way would be to double one of the class selectors, as in .mw-parser-output.mw-parser-output .documentation {} or .mw-parser-output .documentation.documentation {}. This latter way is a little more future-proof but looks a little weirder.!important can always override styles in your personal CSS. The usual caveats regarding !important apply. I prefer one of the two options in bullet two if possible. (You must do this to override inline styles, regardless of the above; some templates cannot move everything to TemplateStyles per the flexibility given to template users. Implementers of templates should consider whether parameters like style and width are necessary. See also phab:T200632.)Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.