Page MenuHomePhabricator

Which tags in MediaWiki should be styled as monospace?
Closed, ResolvedPublic

Description

Is it special that in timeless skin

code, kbd, pre, samp {
    font-family: monospace,monospace;
    font-size: 1em;
}

is no tt tag in it?
In the main vector skin, the tt tag has styles, and in the new skin the content looks different. Should we add styles to a new timeless skin or remove styles from the main vector skin?

Event Timeline

Framawiki subscribed.

Change 377863 had a related patch set uploaded (by Jack Phoenix; owner: Jack Phoenix):
[mediawiki/skins/Timeless@master] Styling for the <tt> tag

https://gerrit.wikimedia.org/r/377863

Then in the MinervaNeue skin it is also necessary to correct

  1. tt is written in the rule and this rule shows it wrong. tt need to be removed from this rule, for example rule does not have the same kbd tag
html,body,div,span,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,ins,em,img,small,strike,strong,sub,sup,**tt**,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,input,textarea,button,select,audio,video {
    margin: 0;
    padding: 0;
    border: 0;
    font: inherit;
    font-size: 100%;
    vertical-align: baseline;
    background: none
}
  1. need to add a rule (it does not exist now in the MinervaNeue skin) - hack increase in size that exists in other skins
pre, code, tt, kbd, samp, .mw-code {
    font-family: monospace,monospace;
}

maybe in the vector replace

pre, code, tt, kbd, samp, .mw-code {
    font-family: monospace,'Courier';
}

by

pre, code, tt, kbd, samp, .mw-code {
    font-family: monospace,monospace;
}

this is a size increase hack (https://books.google.ru/books?id=2bcaAAAAQBAJ&pg=PT49#v=onepage&q&f=false), but Courier at this point in the rule does not look good

maybe in the vector replace

font-family: monospace,'Courier';

by

font-family: monospace,monospace;

this is a size increase hack (https://books.google.ru/books?id=2bcaAAAAQBAJ&pg=PT49#v=onepage&q&f=false), but Courier at this point in the rule does not look good

The book you linked does not display for me, but we also have this documented in the file /docs/uidesign/monospace.html in MediaWiki core.

These two versions are exactly equivalent, I don't think we've been using any of the possible variants of this hack consistently. I grepped core and extensions and found the following number of usages:

RuleUsages
font-family: monospace, 'Courier';18
font-family: monospace, monospace;8
font-family: monospace, fixed;2
font-family: monospace, 'Courer New';1

If you're interested in cleaning this up, can you file another task to track that work? :)

Jdlrobson subscribed.

Minerva uses a css reset. That's why tt is included. All it does is disable any browser default styles.

From my understanding, there are two topics in this task:

  1. Adding tt to monospace selector stack – I would not recommend this, as <tt> is a non-standard element in HTML5 and styling it would just disguise this longer. As the W3C docs clearly state, don't use it. Replace it by <code> or <span>. IMHO this task should be declined.
  2. Unify font stack for monospace styled elements across products, filed under T176636: Unify CSS font stack of monospace-styled elements across products

Removing Vector (legacy skin) and MinervaNeue tags as we will care about it in the newly filed task.

@Volker_E "task should be declined" - tt is redrawn in main skins - vector & monobook from the settings. The content of the page should be equally displayed in all skins. Or tt is redrawn in all skins or need to remove tt redrawing from vector & monobook (equally in all).

https://www.mediawiki.org/w/load.php?modules=mediawiki.skinning.interface

@Sunpriat2 We're talking about an element that has been removed from current HTML standard and is outspokenly marked as “do not use and replace it by code or span. By supporting it by styling it we would just mislead contributors into thinking it's a good idea to use this non-standard element further.
Instead contributors should replace those tags with ones, that are supported.
Special:LintErrors and [[ https://www.mediawiki.org/wiki/Help:Extension:Linter/obsolete-tag | Extension:Linter points out tt ]] as issue and it gets actively replaced currently.

@Volker_E we are talking about a different display of content in the main skin and a new one. It's strange that you are against tt and one-time is not against his presence in the styles of vector skin. "Instead contributors" we are not talking about the contributors, we're talking about skins. Until the skins mimic the tt under the code tags, the contributors will use it.

<code> or <span> - Give us code without a colored background and it will be used where tt tag is used in opposition to the colored code. No one will use long code/span style=... when there is a short tt.

Sunpriat2 updated the task description. (Show Details)
Jdforrester-WMF renamed this task from tt tag to Timeless skin doesn't style the tt tag, but Vector/etc. do.Nov 1 2017, 3:51 PM
  1. Adding tt to monospace selector stack – I would not recommend this, as <tt> is a non-standard element in HTML5 and styling it would just disguise this longer. As the W3C docs clearly state, don't use it. Replace it by <code> or <span>. IMHO this task should be declined.

What you're really advocating is removing styling from the tt elements already declared elsewhere? That seems like a different task to me with its own, longer, consensus process, not least because such a discussion should be had about all of the HTML elements (and I've already seen on a wiki page by @Legoktm a differing opinion [possibly different consensus] about what should happen). We should make the style of tt the same as the others in the short term, IMO.

Jdlrobson renamed this task from Timeless skin doesn't style the tt tag, but Vector/etc. do to Which tags in MediaWiki should be styled as monospace?.Nov 1 2017, 5:45 PM

tt aside, in T179516 there was also a suggestion that MinervaNeue should style kbd, samp, .mw-code as monospace. Are these as debatable as the tt tag? Happy to add them if not.

Change 387835 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[mediawiki/skins/MinervaNeue@master] Style kbd and samp elements as monospace

https://gerrit.wikimedia.org/r/387835

@Jdlrobson 1) kbd and samp do not have a border in a vector 2) you did not add kbd and samp to css reset 3) in T179516 The browser itself changes the tt tag to monospace by default. But in the css reset tt tag equated to the normal text and does not return the monospace for tt - this is an error. If tt tag is used - it is used specially and it is clearly not an ordinary text. In this request for another skin - timeless at least does not use reset.

kbd and samp do not have a border in a vector

Vector is not Minerva. How are these used? Which extensions introduce them? We should have sensible defaults in skins and let the extensions that introduce them enhance those rules further based on their needs.

@Jdlrobson Vector - the main skin on which the content is written. In the vector, code tag has a gray background. tt tag has no background and was used in the text where monospace is needed. kbd and samp used to replace the tt - in the text where the background is undesirable and even in templates - so this border can come out unpredictably where in the article and other templates

Jdlrobson moved this task from Doing to Inbox on the User-Jdlrobson board.

@Sunpriat2 We're talking about an element that has been removed from current HTML standard and is outspokenly marked as “do not use and replace it by code or span. By supporting it by styling it we would just mislead contributors into thinking it's a good idea to use this non-standard element further.
Instead contributors should replace those tags with ones, that are supported.
Special:LintErrors and [[ https://www.mediawiki.org/wiki/Help:Extension:Linter/obsolete-tag | Extension:Linter points out tt ]] as issue and it gets actively replaced currently.

I don't think so. In my opinion, deprecating tt is a needless complification of code. I think if we do this, we don't keep in mind what's helpful for practical use. In many cases I see LintErrors leading to active decline of code readability because editors are "fixing" them. (Not regarding all types of lint errors, just some few, specific ones.)

@MGChecker Wrong fixation by contributors doesn't make styling a deprecated tag and sending code down the wire to all our users any more rightful IMHO. We have both, https://www.mediawiki.org/wiki/Help:Extension:Linter/obsolete-tag and https://en.wikipedia.org/wiki/Wikipedia:Village_pump_(technical)/Archive_131#Time_to_knock_out_obsolete_HTML_tags with clear recommendations.

@MGChecker Wrong fixation by contributors doesn't make styling a deprecated tag and sending code down the wire to all our users any more rightful IMHO. We have both, https://www.mediawiki.org/wiki/Help:Extension:Linter/obsolete-tag and https://en.wikipedia.org/wiki/Wikipedia:Village_pump_(technical)/Archive_131#Time_to_knock_out_obsolete_HTML_tags with clear recommendations.

There is no pain in letting MediaWiki do the interpretation of this obsoletet tags, the brwoser never has to see them. After all, e.g. nowiki an poem are no part of the HTML standard as well, nevertheless we use them, in poems case even to do styling. I might not be the most elegant solution, but I really think it is the most practical.

Change 387835 merged by jenkins-bot:
[mediawiki/skins/MinervaNeue@master] Style kbd and samp elements as monospace

https://gerrit.wikimedia.org/r/387835

@MGChecker When we'd continue to support it, there is a maintenance burden and even more important, volunteers who are not as technically experienced, see it elsewhere working and copy and paste it introducing more deprecated markup for other volunteers to remove. <nowiki> is a MediaWiki specific extension, while <tt> is a deprecated HTML element stated not to used in HTML5 standard published October 2014.

@MGChecker When we'd continue to support it, there is a maintenance burden and even more important, volunteers who are not as technically experienced, see it elsewhere working and copy and paste it introducing more deprecated markup for other volunteers to remove. <nowiki> is a MediaWiki specific extension, while <tt> is a deprecated HTML element stated not to used in HTML5 standard published October 2014.

So why deprecate the markup? If you don't deprecate it, there won't be any problem in continued usage. If you don't rely on HTML, but let it be interpreted by MediaWiki itself, it shouldn't conflict with HTML standards.

interpreted by

so MediaWiki itself rewrites tt (or some tag "mono") into a span?

interpreted by

so MediaWiki itself rewrites tt (or some tag "mono") into a span?

Exactly.

Change 377863 merged by jenkins-bot:
[mediawiki/skins/Timeless@master] Styling for the <tt> tag

https://gerrit.wikimedia.org/r/377863

@MGChecker Because there are viable alternatives already defined: code or kbd. Why leaving it in and making things more complex long-term?
MediaWiki is not an entity on its own, it's part of the Open Web. And the web evolves. With and around browsers and standards. When people come to MW they have to learn a deprecated tag which is nowhere used. That's an unnecessary hurdle.

Volker_E claimed this task.

code, kbd, pre, samp seem sufficient for all other skins. Putting this on resolved, as Timeless decided to go with tt.

@MGChecker Because there are viable alternatives already defined: code or kbd. Why leaving it in and making things more complex long-term?
MediaWiki is not an entity on its own, it's part of the Open Web. And the web evolves. With and around browsers and standards. When people come to MW they have to learn a deprecated tag which is nowhere used. That's an unnecessary hurdle.

These are similar options, but do not produce the same output as tt, which is still supported by MediaWiki skins in general.

Ignoring the issue of styling, kbd has specific semantic meaning (keyboard input) that tt does not, so it's not accurate and is in fact potentially harmful to declare that kbd is an alternative to tt - this is only true in certain cases. The same applies to samp and var. (It also actually applies to code, though I don't know in practice how many people care enough to only present source code using code, and use span for other things.)

As to the deprecation of any given HTML element in HTML 5 (or any other HTML version), there is no reason that should impact wiki markup (or to be more precise, there may be valid reasons to deprecate and eventually remove individual bits of markup, but deprecation of the HTML element they happen to have been styled after are not primary among them). At most, it should impact the output of the parser, but wiki markup is entirely parsed by the parser, so HTML could be entirely replaced tomorrow by, say, an arbitrary binary format, and it wouldn't have to have the slightest impact on wiki markup.

As to the deprecation of any given HTML element in HTML 5 [snip]

I happen to disagree with you, but regardless, I'm pretty sure this is pretty far offtopic to this task. T175709#3726846 is relevant. If we want to have a discussion about the validity of certain HTML tags in wikitext, especially deprecated ones, that should be elsewhere.

It seemed to me on rereading the commentary in this task that there was a lot of confusion between MediaWiki's support of the HTML tt tag, and its implementation of the tt wiki markup element, and my comment was addressing that. My impression, of course, could be entirely mistaken, but that's at least where it was coming from, just to be clear.