My memories in M1x, From xml use aParams tag can add class name for anchor. But in M2 seem this tag have removed. Where can i find this params in code Anyone have experience on this case

@Marius top links from M1 i can use xml to add class name to anchor

xml you can see below link
I want to do that in M2 but seem this way not work. Any idea on this case
What class name will render top links in M2?

Many thanks

  • can you provide an example of what you did in M1 and what do you expect on M2? your question is not really clear.
    – Marius
    Sep 23, 2015 at 8:41
  • @marius take a notice
    – mrtuvn
    Sep 24, 2015 at 2:24

1 Answer 1


If you need add class to top.links block use layouts like

<referenceBlock name="top.links">
       <argument name="css_class" xsi:type="string">my-class</argument>

if you need add new link to top.links use layout like

    <referenceBlock name="top.links">
        <block class="\Magento\Framework\View\Element\Html\Link" name="top-link-myaccount">
                <argument name="label" xsi:type="string">My Account</argument>
                <argument name="href" xsi:type="url">customer/getAccountUrl</argument>
                <argument name="class" xsi:type="string">top-link-myaccount</argument>
  • i have tried this way but getting DOM error
    – mrtuvn
    Oct 2, 2015 at 10:27
  • can you show the layout file
    – KAndy
    Oct 2, 2015 at 11:31
  • dropbox.com/s/btsxnab71kfwnaf/…
    – mrtuvn
    Oct 2, 2015 at 16:31
  • 1
    This way, the A element will get a Class. How can I modify this XML in order to give its li parent element a class?
    – Max
    Oct 6, 2016 at 8:14
  • For some reason <argument name="css_class" xsi:type="string">my-class</argument> does not take effect for anchor elements on M2.1.x Jan 23, 2018 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.