General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion CSS set specific style to second child element

  • JS_Nbg_DE

    CSS set specific style to second child element

    Participants 0
    Replies 1
    Last Activity 5 years, 1 month ago


    is it possible to set a specific style to the second child element?
    In this sample i want the second child element of msub should be shown with vertical-align sub in xMax.


    This don't work:

    msub > *[2] {
      display: inline;
      vertical-align: sub;
      font-size: 0.8em;



    Derek Read

    Reply to: CSS set specific style to second child element

    This type of selector isn't supported. The following would do it but only for this specific case:

    msub > mi mi {
     vertical-align: sub

    That's going to affect all elements that have a before them.

    If you are going to have content where there are more than two elements you would have to write a script to affect just one and not the others. Something similar to the following would do that:

    [code]//XMetaL Script Language JScript:
    //create a Range we can move around to alter style(s) for specific elements
    var rng = ActiveDocument.Range;
    //get all nodes that are the second mi sibling inside msub:
    var nodes = ActiveDocument.getNodesByXPath(“//msub/mi[2]”);
    //loop through the list of nodes, move the Range to each, and set the style(s):
    for(i=0; i rng.SelectNodeContents(nodes.item(i));
    rng.ContainerStyle = “display:inline; vertical-align:sub; font-size:0.8em”;

    Note to anyone that wants to use this approach for DITA: Please don't try. Modifying the DITA customization's scripts is not supported.

    Regarding MathML:
    If you are trying to style MathML to make it easier to edit in XMetaL Author I think that's going to be a lot of work unless you use a very small specific subset and perhaps only use some specific equation layouts. If you use MathML on a regular basis I would highly recommend Design Science's “MathFlow Editor” for XMetaL Author (it works with XMAX as well):


  • You must be logged in to reply to this topic.

Lost Your Password?