Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the Document</title> <style> body { color: red; margin: 20px } </style> </head> <body> <script> let computedStyle = getComputedStyle(document.body); // now we can read the margin and the color from it alert(computedStyle.marginTop); // 20px alert(computedStyle.color); // rgb(255, 0, 0) </script> </body> </html>