Most web browsers, by default, display pages as having a white background. However, this is somewhat user-configurable, and some browsers are different. So, I want to find a way using CSS or JavaScript to find out the background color of the page. The documentation on the Mozilla website suggests that you can use document.bgColor, and its default value is white. He also suggests not using it because it is out of date. But the documents seem to contradict the observed behavior: document.bgColor is an empty line if there is no CSS on the page to change it. The proposed alternatives do not work either: everything I tried gives me either an empty string or a “transparent” one, which is clearly wrong: I do not see the desktop under my browser, therefore it is not transparent. (By the way, IE11 actually behaves the same as in the Mozilla documentation, says Firefox does. Go figure.)
I want to create an html list item ( <ul> ) whose background color matches the background color of the document. Is it possible? (I suppose you might be tempted to ask: "If I want it to match the background, I'm not transparent what I want? No. I want it to cover some other element. Why? Because I'm doing one from these auto tips.)
Edit: 2 people wisely suggested adding an example to make it clear what I'm talking about. Based on the answers I received, these 2 people are absolutely right. I added a link to the violin in the comments of one of the answers, and now I am adding it here:
https://jsfiddle.net/ftgu97fj/5/
source share