CSS styling in Js
We can also style element of html from css.
<body> <h1 id="h1id1">This is first heading</h1> <h1 id="h1id2">This is second heading</h1> <!-- script --> <script> document.getElementById('h1id1').style.color='red';//for single line styling document.getElementById('h1id2').setAttribute("style", 'color:red; background: green; text-align:center; border-radius: 2rem; border: 1rem solid black'); </script> </body>
Top comments (0)