Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

210
Views
Changing the background property of the html, not the body

How do I change the background property of the html? I was able to change the background of the body element, but I want to manipulate the html "tag" (?).

Code to manipulate the body background

document.body.style = 'background: radial-gradient(circle, rgba(131,170,203,1) 4%, rgba(69,113,148,1) 50%, rgba(39,71,97,1) 100%);';

These attempts didn't work

document.html.style = 'background: red';
document.style = 'background: red';

I want to change this part

html {
    font-family: Arial, Helvetica, sans-serif;
    color: white;
    -webkit-user-drag: none;
    user-select: none;
    -moz-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;

    background: radial-gradient(circle, rgba(131,170,203,1) 4%, rgba(69,113,148,1) 50%, rgba(39,71,97,1) 100%);
}
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

You need to use document.documentElement.style to target the html element.

document.body.style = 'background: radial-gradient(circle, rgba(131,170,203,1) 4%, rgba(69,113,148,1) 50%, rgba(39,71,97,1) 100%);';

document.documentElement.style = 'background: red';
<html>
  <body>
    <p>test</p>
  </body>
</html>

about 4 years ago · Juan Pablo Isaza Report

0

change background by javascript in html tag try this :

document.getElementsByTagName('html')[0].style.background="radial-gradient(circle, rgba(131,170,203,1) 4%, rgba(69,113,148,1) 50%, rgba(39,71,97,1) 100%)";

about 4 years ago · Juan Pablo Isaza Report

0

just put a background-div in the DOM and manipulate it. e.G. position: absolute / z-index: -1

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!