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

116
Views
CSS: Apply Filter of type URL() to all elements

I am trying to apply a filter to the body of my page using filter: url(#filter_id), but im not managing to make it work.

This is how im adding it to the styling:

document.body.style.filter = 'url("#filter_id")'

and this is how i am creating the filter

var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
svg.setAttribute("width","0" )
svg.setAttribute("height","0" )

var filter = document.createElement("filter");
filter.setAttribute("id","filter_id" )

var feColorMatrix = document.createElement("feColorMatrix")
feColorMatrix.setAttribute("type","matrix")
feColorMatrix.setAttribute("values","1 1 1 1 0 0 1 1 1 0 0 0 1 0 0 0 0 0 1 0")

filter.appendChild(feColorMatrix)
svg.appendChild(filter)

document.body.prepend(svg)

this creates the filter element on the top of the body:

<filter id="filter_id">
<fecolormatrix type="matrix" values="1 1 1 1 0 0 1 1 1 0 0 0 1 0 0 0 0 0 1 0"/>
</filter>

How can i apply it to the full page so that every element gets the color shift that i intend? For context, this is currently employed in a chrome extension im developing.

If i do other types of filters it works (applies to the full page)

document.body.style.filter = "blur(1px)"
about 4 years ago · Juan Pablo Isaza
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!