link css to js code example
Example 1: how to link javascript to html and css
# Javascript
<script src="[file_name].js"></script>
# CSS
<link rel = "stylesheet" type="text/css" href = "style.css" />
Example 2: append css file with javascript
var cssFile = document.createElement('link');
cssLink1.rel = 'stylesheet';
cssLink1.href = "styles.css";
document.head.appendChild(cssFile);
Example 3: js add css to document
document.querySelector('head').innerHTML += '<link rel="stylesheet" href="styles.css" type="text/css"/>';