Difference between revisions of "Template:Code"
(Created page with "<includeonly><span class="Template-code" style="display:none" data-styles="{{{css|}}}" data-html="{{{html|}}}" data-param="{{{param|}}}"></span></includeonly><noinclude>Use th...") |
|||
| Line 1: | Line 1: | ||
| − | <includeonly><span class="Template-code" style="display:none" data-styles="{{{css|}}}" data-html="{{{html|}}}" data-param="{{{param|}}}"></span></includeonly><noinclude>Use this template to write HTML and CSS code. Writing HTML with this template can be useful if you want to add elements that MediaWiki normally would'nt allow you to in the wikitext like <input> or <label>. Additionally, Unlike normal inline styles, this template allows advanced CSS features like functions, media queries, and pseudo-classes. | + | <includeonly><span class="Template-code" style="display:none" data-styles="{{{css|}}}" data-html="{{{html|}}}" data-param="{{{param|}}}" data-param2="{{{param2|}}}"></span></includeonly><noinclude>Use this template to write HTML and CSS code. Writing HTML with this template can be useful if you want to add elements that MediaWiki normally would'nt allow you to in the wikitext like <input> or <label>. Additionally, Unlike normal inline styles, this template allows advanced CSS features like functions, media queries, and pseudo-classes. |
| Line 10: | Line 10: | ||
}} | }} | ||
</pre> | </pre> | ||
| − | The <code>param</code> parameter allows you to pass parameters inside the html code. An example can be found in [[Template:cover]]. | + | The <code>param</code> and <code>param2</code> parameter allows you to pass parameters inside the URL-encoded html code. An example can be found in [[Template:cover]]. |
Latest revision as of 23:38, 8 June 2025
Use this template to write HTML and CSS code. Writing HTML with this template can be useful if you want to add elements that MediaWiki normally would'nt allow you to in the wikitext like <input> or <label>. Additionally, Unlike normal inline styles, this template allows advanced CSS features like functions, media queries, and pseudo-classes.
HTML:
For HTML, enter the URL-encoded code in the html parameter. You can use this simple URL encoding tool
{{code
|html=%3Cinput%20type%3D%22checkbox%22%20id%3D%22checkbox%22%2F%3E%0A%3Clabel%20for%3D%22checkbox%22%3EClick%20Me%3C%2Flabel%3E
}}
The param and param2 parameter allows you to pass parameters inside the URL-encoded html code. An example can be found in Template:cover.
CSS:
For CSS, you can write the styles normally in the css parameter
{{code
|css=body {
color: red;
}
img:hover {
transform: scale(1.03);
filter: brightness(0.85);
}
@media screen and (max-width: 450px) {
html {
font-size: 80%;
}
}
}}
Please note that the code written with this template will take effect after a page has loaded. So if possible, avoid using this template for elements that are at the very top of a page (like InfoBox TV), or else the elements might look weird for a few seconds.