This was a surprise. The following code does not seem to give me the actual colors on the screen:
h1 = document.querySelector("h1"); window.getComputedStyle(h1).color
Gives rgb(0, 0, 0) which I think is correct. but
window.getComputedStyle(h1).backgroundColor
gives rgba(0, 0, 0, 0) . The actual background color that I see on the screen is white.
The element that I call h1 is displayed on the screen. I expected to get the actual background color. The value I get above (in rgba) is not wrong, but not very useful. He just tells me that the background is completely transparent - and that is not the color.
How to get the actual background color in RGB?
javascript html background-color css
Leo
source share