0

I am adding the fonts as specified in magento 2.3 documentation however i am getting the error

Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'font': This element is not expected. Expected is one of ( title, css, link, meta, script, remove, attribute ).

I am adding font as

<font src="fonts/opensans/light/opensans-300.woff2"/>

1 Answer 1

0

You can add like this in your xml file :

<link rel="preload" href="fonts/opensans/light/opensans-300.woff2" as="font"/>
5
  • Thank you. So far all good however it is giving me this error Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'link', attribute 'crossorigin': The attribute 'crossorigin' is not allowed. Jul 11, 2021 at 11:17
  • Thanks. Happy coding !! Just remove crossorigin attribute if you added in link tag. Jul 11, 2021 at 11:54
  • Thank you. I did the same however more problems coming with magneto. If i put multiple fonts as <link rel="preload" src="fonts/icomoon.woff" as="font"/> <link rel="preload" src="fonts/VarelaRound-Regular-webfont.woff" as="font"/> preloading it not loading and giving me error that Exception #0 (InvalidArgumentException): Merge for content type 'woff' is not supported. What i did I put the same in Design > configuration > Header and now it works but in default_head_blocks.xml its not working at all Jul 11, 2021 at 12:50
  • It's really strange..!! It should be working but maybe something wrong in your file. Jul 11, 2021 at 13:48
  • this is not working at Magento 2.3.7
    – TheFrakes
    Aug 22 at 11:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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