Help talk:Whitespace

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
WikiProject iconWikipedia Help NA‑class Top‑importance
WikiProject iconThis page is within the scope of the Wikipedia Help Project, a collaborative effort to improve Wikipedia's help documentation for readers and contributors. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks. To browse help related resources see the Help Menu or Help Directory. Or ask for help on your talk page and a volunteer will visit you there.
NAThis page does not require a rating on the project's quality scale.
TopThis page has been rated as Top-importance on the project's importance scale.

Spaces between text and comment[edit]

The section "Invisible comments", written by SchmuckyTheCat and Redrose64 in about 2011, tells editors to remove whitespace between text and an HTML comment (i.e invisible comment: <!-- This is an invisible comment -->) by "ensuring either that the initial < touches the text immediately beforehand, or that the final > touches the text immediately afterwards" because it could result in unwanted whitespace being added. It seems that inserting spaces between text and comments does not result in unwanted whitespace or at least not any more now in 2023. I feel that the entire section should be deleted or possibly be replaced by a text describing a case where adding whitespace between text and comment really results in the addition of unwanted whitespace if such a case still exists. With thanks and best regards, Johannes Schade (talk) 19:16, 25 August 2023 (UTC)[reply]

You can't delete the whole section. This still produces whitespace if there are two newlines between text and a comment. This is extremely common when editors comment out a paragraph of uncited text.
Templates interact in weird ways with leading and/or trailing comments. Leaving no spaces (especially a newline) at the beginning and end of a template is still good advice.
There's no objective goal in removing this advice other than source beautification. Remember that Wikipedia isn't the only project that uses Wikipedia's source. Since this appears to be a change in MediaWiki behavior translating wiki source to html, we don't know the impact of this on other downlevel projects with different/older rendering engines. Best to leave the advice as is, rather than make the source look clean at the expense of the output looking dirty downstream.
SchmuckyTheCat (talk) 00:56, 26 August 2023 (UTC)[reply]
When I wrote this, the direct caution was against the markup
... the end of a paragraph.
 
<!-- Don't use hidden comments in this manner -->
 
The beginning of a paragraph ...
that is: text, two newlines, a comment, two newlines and text. If you use markup like that, as here, you still get an extra-broad gap between paragraphs: the behaviour has not changed in twelve years. --Redrose64 🌹 (talk) 20:29, 26 August 2023 (UTC)[reply]