Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <head> <style> #myDIV { width: 300px; height: 300px; background-color: coral; color: white; } </style> </head> <body> <h1>HTML Style Object</h1> <h2>The backgroundColor Property</h2> <p>Click the "Try it" button to set the backgroundColor property of the DIV element to "lightblue":</p> <button onclick="myFunction()">Try it</button> <div id="myDIV"> <h1>Hello</h1> </div> <script> function myFunction() { document.getElementById("myDIV").style.backgroundColor = "lightblue"; } </script> </body> </html>