This is how you access the <body> element to set a background style:
document.body.style.background = '';
But how can I access the <html> element in a similar manner? The following doesn’t work:
document.html.style.background = '';
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
<html>element can be referred through thedocument.documentElementproperty. In general, the root element of any document can be referred through.documentElement.Note:
.style.backgroundreturns the value forbackgroundas an inline style property. That is, defined using<html style="background:..">. If you want to get the calculated style property, usegetComputedStyle: