1// Bad:
2element.setAttribute("style", "background-color: red;");
3// Good:
4element.style.backgroundColor = "red";
5
1<!-- Answer to: "html css javascript" -->
2
3<!--
4 To keep things simple:
5 HTML provides the basic structure of sites, which is enhanced and
6 modified by other technologies like CSS and JavaScript. CSS
7 is used to control presentation, formatting, and layout.
8 JavaScript is used to control the behavior of different elements.
9-->
10
11For example:
12<!--HTML-->
13<div id="me">Click me!</div>
14<!--CSS-->
15<style>
16 div {
17 height: 128px; /* Makes the div 128px in height */
18 width: 128px; /* Makes the div 128px in width */
19 background: red; /* Makes the div's background, red */
20 }
21</style>
22<!--JS-->
23<script>
24 document.getElementById("me".addEventListener("click", function(){
25 document.getElementById("me").style.background = 'blue';
26 });
27</script>
28<!-- If you want to test the code above, go to:https://www.w3schools.com/code/tryit.asp?filename=GDZ0PJDLYQ1V -->
29
30<!--
31 For more information, go to:
32 https://blog.hubspot.com/marketing/web-design-html-css-javascript
33-->
1<head>
2
3<script>
4function myFunction() {
5 var x = document.createElement("LINK");
6 x.setAttribute("rel", "stylesheet");
7 x.setAttribute("type", "text/css");
8 x.setAttribute("href", "styles.css");
9 document.head.appendChild(x);
10}
11myFunction()
12</script>
13
14</head>