use css in js code example
Example 1: add style javascript
// Bad:
element.setAttribute("style", "background-color: red;");
// Good:
element.style.backgroundColor = "red";
Example 2: how to give css style in javascript
document.getElementById("myH1").style.color = "red";
Example 3: use css in cshtml
<link rel="stylesheet" href="app.css" type="text/css" />
Example 4: html css js
<!DOCTYPE html>
<html lang="pt-br" xml:lang="fr" xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<title>...</title>
</head>
<body>
...
<script type="text/javascript" src="script.js"></script>
</body>
</html>
Example 5: how to change css using javascript
document.getElementById("myText").className = "anyNewClass"
Example 6: how to change an element in a different elements code css
#container:hover > #cube { background-color: yellow; }
#container:hover + #cube { background-color: yellow; }
#container:hover #cube { background-color: yellow; }
#container:hover ~ #cube { background-color: yellow; }