Wikipedia talk:TemplateStyles

From Wikipedia, the free encyclopedia

Sitewide CSS, again

Six months after the aborted #RfC: converting sitewide CSS to TemplateStyles, I think it is time to revisit this. Would something like Should bots be permitted to make edits in support of migrating sitewide CSS to TemplateStyles? be a helpful RFC question? I believe such a question would if successful unfreeze Wikipedia:Bots/Requests for approval/William Avery Bot 5 while also avoiding RfC after RfC on similar issues (if we need further bots). (And in hindsight I apologize for the terrible RfC question I asked six months ago; re-reading it I am wondering why I thought that would help. Live and learn.) HouseBlaster (talk · he/they) 23:48, 19 August 2024 (UTC)

Blank paragraph following infobox

The TemplateStyles for {{Chembox}} seem to be put in a <p>...</p> element after the infobox, whose only content is a <style>...</style> element containing the styles. Since there's no visible content in this <p>, it appears as a spurious blank line before the first paragraph. This is visible for example at Salicylic acid. Can this <p> be eliminated somehow? Hairy Dude (talk) 02:45, 20 December 2024 (UTC)

While the extra <p> is indeed present in the HTML code, the problem is not visible for me: completely hiding the paragraph doesn’t change the appearance, not even by a few pixels. So it doesn’t look like a huge problem for me. (I use the default Vector 2022 skin.)
However, if it does look like a problem for you, the styles can be moved to within the table, for example in the caption. —Tacsipacsi (talk) 23:43, 21 December 2024 (UTC)
For Salicylic acid, the HTML body (in default Vector 2022 skin) has the usual preamble (mostly <div>...</div> elements), then the page content is:
  • a <div>...</div> for the short description emitted by the {{Short description|Chemical compound used in medicines and industry}}
  • a <p>...</p> element containing a <style>...</style> element, the content of this being taken from Template:Chembox/styles.css
  • a <table>...</table> for the {{chembox}}
  • another <div>...</div> for the short description automatically emitted by the {{Chembox}}
  • a <p>...</p> element containing the lead paragraph: Salicylic acid is an ...
There is no extra <p>...</p> element after the infobox. --Redrose64 🌹 (talk) 15:42, 22 December 2024 (UTC)
I’m pretty sure it’s a typo, and Hairy Dude actually meant the <p> element before the infobox: since the <templatestyles> element is there in the wikitext, it’s the only place it could have any effect. —Tacsipacsi (talk) 17:19, 22 December 2024 (UTC)
Revisiting this. It is definitely there. Perhaps only visible on mobile? It is very obvious to me. Inspecting page source shows a <style> element inside a <p> immediately before the first paragraph, which is before the infobox (since it gets moved on mobile). Hairy Dude (talk) 23:02, 15 September 2025 (UTC)
Looks like there are a few things going on here.
  1. The <nowiki /> used in templates like {{Use dmy dates}} and {{cs1 config}}, there to suppress MediaWiki otherwise seeing completely blank lines from these no-output templates which produces extra paragraph breaks, normally produces a <p> with a class mw-empty-elt, which hides the paragraph entirely using CSS.
  2. But the <templatestyles> tag (or the <style> tag it turns into, not sure which) from TemplateStyles gets merged into that empty paragraph, so it's not technically "empty" anymore to MediaWiki, so MW doesn't generate the mw-empty-elt class.
  3. But it still works on most skins because the space between paragraphs is done entirely with CSS margins, which all wind up collapsing when the browser sees the 0-height paragraph. But for some reason Minerva uses some CSS padding to generate some of its spacing between paragraphs, which prevents the collapsing.
  4. While the moving of the infobox does happen, I don't think it's actually relevant to the problem here. 😀
HTH. Anomie 02:14, 16 September 2025 (UTC)

Discussion at Wikipedia:Village pump (technical) § Template:TemplateStyles sandbox bad title

 You are invited to join the discussion at Wikipedia:Village pump (technical) § Template:TemplateStyles sandbox bad title. VectorWorld (talk) 13:43, 5 November 2025 (UTC)

"Templatestyles" listed at Redirects for discussion

The redirect Templatestyles has been listed at redirects for discussion to determine whether its use and function meets the redirect guidelines. Readers of this page are welcome to comment on this redirect at Wikipedia:Redirects for discussion/Log/2025 December 22 § Templatestyles until a consensus is reached. Casablanca 🪨(T) 20:08, 22 December 2025 (UTC)

Related Articles

Wikiwand AI