Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript How to load CSS using javescript Re: How to load CSS using javescript

#121827
rosspenman
Participant

It is indeed possible.

var s = document.createElement(‘link’);
s.setAttribute(‘href’, ‘style.css’);
document.head.appendChild(s);

But sometimes using JavaScript isn’t the best idea. Have you thought about using media queries instead?