Page MenuHomePhabricator

<strike> tag is deprecated in HTML5; normalize to <s> in parser/sanitizer
Closed, DeclinedPublic

Description

Author: ejsanders

Description:
...and should be replaced by <del> tags. All the UAs I've checked render this is
struck-through text, although the w3c spec does not require this - so it could
be enforced with CSS.


Version: unspecified
Severity: enhancement

Details

Reference
bz4557

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 21 2014, 9:02 PM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz4557.
bzimport added a subscriber: Unknown Object (MLST).

They're still legal, no reason to change them. If at some point we transition to
XHTML 1.0 Strict or some other version without those elements, then of course we
could output a different element type conforming with those specs.

ejsanders wrote:

Indeed, but it's better not to use deprecated tags. Surely it's fairly simple to
implement?

Not better; just more complicated with no benefit. The idea of deprecating <s> isn't to blindly
replace them all with <span style="font-decoration: strikethrough">; it's to plan to use
semantically appropriate elements or classes when you write new documents.

If we *had* to perform such blind replacement, such as for outputting a future version of HTML
that doesn't support <s>, we could do so. But doing so with XHTML 1.1 Transitional doesn't make
any sense. It doesn't make the code semantically better. It doesn't make it more compatible. It
doesn't make it more meaningful. It doesn't do anything but complicate the code and increase
the size of output.

  • Bug 7924 has been marked as a duplicate of this bug. ***

HTML 5 appears to have obsoleted <strike> but *not* <s>:

http://dev.w3.org/html5/spec/obsolete.html#non-conforming-features

Judging by the spec actually, <s> sounds more right than <del> for most usages other than document addition/removal markup:

http://dev.w3.org/html5/spec/text-level-semantics.html#the-s-element
http://dev.w3.org/html5/spec/edits.html#the-del-element

I don't see any active use of <strike> in MediaWiki or any of our SVN extensions; it's allowed through the HTML sanitizer, and that would be the place to normalize it to <s> if necessary in future.

Retooling this to an enh request to normalize <strike> to <s>.

smccandlish wrote:

Brion Vibber wrote:

Retooling this to an enh request to normalize <strike> to <s>.

That sounds entirely reasonable, and it really can be done any time, because <strike> and <s> ARE semantically identical. FWIW, I tend to agree with others that replacing both with CSS that amounts to <span style="font-decoration: strikethrough;"> actually IS perfectly fine, from a code properness point of view (the two elements don't mean anything semantic, only presentational, i.e. "this is struck-through text", which is precisely what the CSS version means), but I also agree with the counterpoint that it doesn't really buy us anything and make the code longer. No reason to do that if HTML5 will still support <s> as non-deprecated markup. And I concur that they are not interchangeable with <del>. Many editors on Wikipedia use them all as if they were, but this is a mistake.

Note that this kind of normalization can also break stuff, such as CSS rules set for 'strike' (both in core as well as extensions and site/user scripts).

Technically HTML5 actually defines <s> as "The s element represents contents that are no longer accurate or no longer relevant." rather than as a strike-through. But that probably doesn't really matter since HTML4 defined both <strike> and <s> as strike-through. So whether you used <strike> or <s> HTML5 still changes the semantics.

So, remove support for it from wiki text?

I would support that with 1000 points, but it won't likely happen, since we still allow things like <center>, <font>, <tt>, <big> (T40487: Remove button for <big> from toolbar sic!) etc...