Skip to content

Simplification of the mstyle element #1

Closed

Description

@fred-wang

This proposal is to simplify mstyle so that it only supports the following attributes:

  • displaystyle
  • dir
  • mathsize
  • mathbackground
  • mathcolor
  • mathvariant
  • scriptlevel

And maybe:

  • scriptsizemultiplier
  • scriptminsize

From the Math WG mailing list:
https://lists.w3.org/Archives/Public/www-math/2016Jul/0024.html

From the appendix of the original "MathML in HTML5" document:
"The mstyle element duplicates the CSS inheritance mechanism in a CSS-incompatible way and has many exceptions to workaround the fact that attribute names may be used for different purposes. In practice, many of its attributes are not useful and never used. It is a burden for implementers since they essentially have to reimplement a specific “attribute” inheritance mechanism to support the general case even if the most prominent attributes have obvious mapping to CSS. It is also a performance issue to perform the rendering and keep it up-to-date since the rendering on any node may depend on its mstyle ancestors. In this document, it instead suggested to keep only attributes that are compatible with CSS and five new CSS properties are introduced in section 2.3.1. These attributes actually correspond to what is used in practice. "

edit:
This is the proposal for CSS attributes that cannot be mapped to style yet: https://github.com/mathml-refresh/mathml-css-proposals#mathml-css-proposals

Activity

  1. physikerwelt commented on Feb 19, 2019

    @physikerwelt
    Member

    This might be a stupid question, but why do we need

    • dir -> direction
    • mathsize -> font-size
    • mathbackground -> background-color
    • mathcolor -> color
      can that not implemented using the style attribute?
  2. fred-wang commented on Feb 19, 2019

    @fred-wang
    Author

    Yes, they can be (and are) implemented using CSS style.
    Whether we want to remove/deprecate these MathML attributes (and hence the whole mstyle element) is another question, but probably they have already been used a lot in existing documents. This is not really the case of attributes not mentioned in #1 (comment) , I think in a previous discussion on Math WG only one instance of another attribute (linethickness) was used in the MathML 3 test suite.

  3. fred-wang commented on Feb 19, 2019

    @fred-wang
    Author

    Incidentally, for attributes without CSS equivalent, there is https://github.com/mathml-refresh/mathml-css-proposals#mathml-css-proposals

    @physikerwelt I think in general it would be good to gather usage metrics of elements/attributes that are proposed for deprecation/removal. Maybe you can do that for wikipedia.

  4. davidcarlisle commented on Feb 19, 2019

    @davidcarlisle
    Collaborator

    This might be a stupid question, but why do we need

    * dir -> direction
    
    * mathsize -> font-size
    
    * mathbackground -> background-color
    
    * mathcolor -> color
      can that not implemented using the style attribute?
    

    html also has a dir attribute so this isn't so strange I think?

    Initially the model was to preserve as far as possible that as far as possible the notion that css should be used to encode potentially reader-customizable style, and that explicit attributes in the source should be used to encode author-specified meaning.

    So a clearer example would be <mi mathvariant="sans-serif" to chose a sans math alphabet as opposed to using CSS to chose the overall font style (which may be sans serif)

    Of course in the end mathvariant got defined as a shift of codepoint rather than a change of font, but it was still a motivating example here.

    So at the time, almost all publications were monochrome but the thought was that you may want to use colour just as fonts have been traditionally used, to have distinguished mathematical variables x mathcolor="red" and x mathcolor="blue" that are separate from a reader choice to style the whole expression in brown to match a website style...

    We can decide not to keep this (and we could potentially have different decision for the mathml-core and full mathml but if you are asking why mathml3 (and 2 and 1) are this way, that is basically why.

  5. added
    MathML Core
    MathML 4
    css / html5
    on Feb 22, 2019
  6. dani31415 commented on Feb 25, 2019

    @dani31415

    Why not indentalign -> text-align ?

  7. physikerwelt commented on Feb 25, 2019

    @physikerwelt
    Member

    discussed in the telco on 2019-02-25:

    • @NSoiffer does not think one can get rid of mstyle entirely?
      ** @fred-wang "in theory one could get rid of mstyle and use style of mrow"
    • can one get rid of matvariant?
    • patrick ion asks if there are glyphs that are only accessible via mstyle?
  8. fred-wang commented on Mar 14, 2019

    @fred-wang
    Author

    Why not indentalign -> text-align ?

    I don't think indentalign is in MathML Core. Also we should keep in mind (2) #30 (comment) applies here.

  9. fred-wang commented on Mar 14, 2019

    @fred-wang
    Author

    This is how I understand the current status:
    (1) Do we keep the <mstyle> element? It could just be <mrow> + CSS styles but we need (a) to define more CSS properties / remove some attributes and (b) take into account non-browser implementation and backward compatibility with existing usage #55.
    (2) Do we reduce the existing set of properties (suggestion: #1 (comment)).
    (3) Do we just map properties to CSS instead of defining our own inheritance?
    (4) Do we move new proposals https://github.com/mathml-refresh/mathml-css-proposals to CSS -drafts?. Per https://lists.w3.org/Archives/Public/public-mathml4/2019Mar/0007.html for mathvariant it seems fine to extend CSS text-transform and displaystyle is not really controversial. I hope we can decide about scriptlevel-related properties in the next meeting.

  10. dani31415 commented on Mar 15, 2019

    @dani31415

    I think we should make MathML core as much backward compatibility as possible with existing formulas. With this idea we should implement the <mstyle>.

    At the same time I would deprecate <mstyle> in the sense that we recommend to use the alternative version of <mrow> with CSS. In addition, in MathML 4, I would deprecate <mstyle> as well (with the same meaning of a recommendation of not to use it).

  11. fred-wang commented on Mar 19, 2019

    @fred-wang
    Author

    cc @rwlbuis @emilio

    We have discussed a lot about scriptlevel yesterday. This is my summary regarding the attributes:

    Given all of this, I would now recommend to remove scriptsizemultiplier and scriptminsize attributes from MathML Core and only keep thoses:

    • displaystyle (mapped to a new two-valued CSS property)
    • dir
    • mathsize
    • mathbackground
    • mathcolor
    • mathvariant (mapped to new text-transform values)
    • scriptlevel (mapped to a new property)

    Details for the last one still have to be discussed in #31

  12. added
    compatibility
    on Mar 20, 2019
  13. fred-wang commented on Mar 22, 2019

    @fred-wang
    Author

    @brucemiller mentioned that LaTeXML sometimes generates href on mstyle ( #55 (comment) ).

    First, I'd like to clarify that this proposal is not about generic MathML attributes on mstyle ( like https://mathml-refresh.github.io/mathml/chapter2.html#fund.globatt or https://mathml-refresh.github.io/mathml/chapter3.html#presm.presatt ) but only about those related to this MathML 3 "inheritance".

    Also, this raises yet another issue with the MathML 3 mstyle model. https://mathml-refresh.github.io/mathml/chapter3.html#presm.mstyle already has an exception for mathbackground/mathcolor saying that it applies to the mstyle itself, not to descendants. Such an exception should also apply to href.

  14. 31 remaining items

  15. fred-wang commented on Aug 19, 2020

    @fred-wang
    Author

    In the last comment on this (Apr 2019) which is about a meeting resolution, only dir, mathsize, mathbackground, mathcolor were listed as being agreed to keep in core. mathvariant is not on the list.

    This github comment is not complete, the proposal was #1 (comment) and summary says

    • maps displaystyle, mathvariant, scriptlevel to CSS
    • remove scriptsizemultiplier and scriptminsize
    • dir, mathsize, mathbackground, mathcolor: map attribute to existing CSS property
    • Remove all the other mstyle attributes

    which is what we've try to do in the spec/tests/implementation.

    I agree mathvariant is still used, but I don't believe anyone ever sets it on mstyle as it is not a useful thing to do. I don't think we have statistics on its usage on mstyle though so we don't have any info on that front to use in this discussion.

    Two points:

    • AFAIK MathJax (and so wikipedia) does not use Unicode characters, but the mathvariant attribute instead. And there are others tools using mstyle@mathvariant (like itex2MML). So we would need to convince them first or claim polyfill is good enough in that case.

    • As discussed during core meeting, restricting to token elements actually makes things more slightly complicate for browsers since you need to perform per-tag check and have the corresponding tests to check attributes apply to a specific list of elements. So I still don't understand what's the point of doing that? The only explanation is #204 but it can be solved by introducing universal selector, if it's considered a bug rather than a feature. I also prefer consistency and say that "MathML stylistic attributes apply to all mathml elements and are just mapped to CSS properties" which is easy to understand.

    Also, it isn't clear that CSS will support the text-transform change needed as it is not in the latest working draft of CSS Text Module Level 3 so the current Chromium implementation may not be supportable on all platforms.

    We definitely need automatic mathvariant italic in any case for single-char mi. If the CSS WG rejects or wants change to mathvariant or other proposals then we can adapt accordingly, but I don't think we need to agree before we actually get their feedback. Also IIUC Brian said our text-transform proposal is uncontroversial in the CSSWG now. I think the risk is more on the scriptlevel stuff.

  16. NSoiffer commented on Dec 19, 2024

    @NSoiffer
    Contributor

    I think the "needs resolution" and "needs specification update" labels can be removed, leaving only the need to implement the polyfill.

    @fred-wang, @davidcarlisle: agree?

  17. davidcarlisle commented on Mar 15, 2025

    @davidcarlisle
    Collaborator

    This is a very old issue, just reviewing the current state, mostly mathml4 presentation follows core and makes the relevant attributes valid on all elements. Assuming #531 is merged <mstyle> is the same as <mrow> except that it allows 4 additional attributes (that are not in Core) as such it can't really be simplified a lot more unless we drop it completely. Although we could make those 4 attributes "attributes common to presentation elements" and just say mstyle is the same as mrow kept for legacy reasons.

    So in answer to @NSoiffer's comment above, we could leave specification as is (and remove the label) or simply further.

  18. davidcarlisle commented on Jul 3, 2025

    @davidcarlisle
    Collaborator

    Consensus at meeting today was to consider moving towards core and allow displaystyle and other attributes on all presentation elements, this would affect the details here. To be investigated Note the spec already says this in https://w3c.github.io/mathml/#presm_presatt_core but is not consistently carried through the rest of the spec.

    Note decimalpoint attribute can be dropped

  19. removed
    need resolution
    on Sep 11, 2025
  20. NSoiffer commented on Nov 11, 2025

    @NSoiffer
    Contributor

    Changing the spec is looking more complicated than I first thought. Unlike core, full has content and presentation elements. In particular, we have 3.1.9 Mathematics attributes common to presentation elements. That's probably where the majority of the contents of mstyle should move to. Not to Chapter 2 which talks about attributes common to all elements. That section probably needs to be updated to brought into sync with core (I think there are a few differences)

    But mstyle also says:

    Other attributes, such as linethickness on mfrac, have default values that are not normally inherited. That is, if the linethickness attribute is not set on the mfrac element, it will normally use the default value of medium, even if it was contained in a larger mfrac element that set this attribute to a different value. For attributes like this, specifying a value with an mstyle element has the effect of changing the default value for all elements within its scope.

    That's a difference from what core does, so we can't say that in full, mstyle is the same as mrow as is done in core.

    Also, contrary to what is said in #1 (comment), decimalpoint can't be dropped. "decimalpoint" is a somewhat misleading name as it isn't about alignment: it specifies the character to use for decimal alignment if that is chosen (with the malign deletion, only relevant to mstack's stackalign attr if the value is "decimalpoint"). Potentially it should be renamed to "decimalcharacter" to avoid confusion with the attribute value.

  21. davidcarlisle commented on Nov 11, 2025

    @davidcarlisle
    Collaborator

    yes exactly, that is also the way the schema handles it,

    https://www.w3.org/TR/mathml4/#parsing_rnc_core

    Global attributes in core are the list MathMLPGlobalAttributes which is included into the presentation mathml schema (not content mathml) at https://www.w3.org/TR/mathml4/#parsing_rnc_pres which extends it in various ways eg

    MathMLPGlobalAttributes &=
    		   NonMathMLAtt*,
    		   attribute xref {text}?,
                       attribute href {xsd:anyURI}?
    

    to add href but that list is still included into all presentation elements both from core and ones added in mathml full.

    So I'd expect to add decimalpoint there, which would equate to adding it to 3.19 as you state.

    I don't find it too confusing to have decimalpoint both as an attribute and an attribute value, but as you say current use isn't that great so we could rename the attribute, and keep decimalpoint just as the name of the alignment to go in attribute values.

  22. removed
    need specification update
    on Apr 30, 2026
  23. davidcarlisle commented on May 31, 2026

    @davidcarlisle
    Collaborator

    @NSoiffer is this now covered by the polyfills?

  24. NSoiffer commented on Oct 22, 2026

    @NSoiffer
    Contributor

    Wrote a polyfill last week, so this can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    MathML 4compatibilitycss / html5need polyfill

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions