I’m working with a CMS that prevents us from editing the head section. I need to add css stylesheet to the site, right after the tag. Is there a way to do this with JS, where I can add a script to the bottom of the page (I have access to add script right before the tag) that would then inject the stylesheet into the head section?
Share
Update: According to specs, the
linkelement is not allowed in the body. However, most browsers will still render it just fine. So, to answer the questions in the comments – one really has to addlinkto theheadof the page and not thebody.Or a little bit easier with jquery
Original answer:
You don’t need necessarily add it to the head, just add it to the end of body tag.
as Juan Mendes mentioned, you can insert stylesheet to the head instead
And the same without jQuery (see code above)