Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Can I use DOM in CSS?

Posted on 2006-07-04
Last Modified: 2013-11-19
Can I use DOM in CSS? I want the set the bgColor of an element to the bgColor of the parent by using CSS – How can I?
Question by:madchat1
  • 3
  • 2
LVL 49

Expert Comment

ID: 17040304
You can set the element to be transparent:
#parentDivId element {background:transparent;}


Author Comment

ID: 17040325

I tried transparent by it's no good coz in FireFox it doesn't work so well.
(And what does #parentDivId mean? Why do need the parent if it is transparent)

LVL 49

Accepted Solution

Roonaan earned 125 total points
ID: 17040348
The official answer to your question would be: No you cannot use DOM in crossbrowser CSS.

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

LVL 15

Expert Comment

ID: 17041558
Actually, you can use JavaScript in your CSS files. However, it's only executed once, so it may not be just what you want (see http://www.quirksmode.org/css/javascript.html). An alternative is to manipulate the CSS in onPageLoad, where you can set the colors as you wish.
LVL 49

Expert Comment

ID: 17041634

That is why I wrote it in this way: "No you cannot use DOM in --> crossbrowser CSS <--."

LVL 15

Expert Comment

ID: 17041785
Yes, Roonan, the embedded JS in CSS only works in IE and Opera (and is regarded as a naughty thing to do). However, the idea of manipulating styles in an onload function is perfectly valid and works across browsers.

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Scroll 5 news at a time. 4 33
I am having a  Git   issue 6 42
Sending an input value from a view to a controller in MVC 3 23
Web Easy Professional 10 Embedded Facebook 1 17
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question