Forum Moderators: coopster

Message Too Old, No Replies

Associating stylesheet info with corresponding HTML tag, id or class

PHP DOM to read HTML and associate it with corresponding stylesheet element

         

gijoe

5:52 pm on Nov 20, 2009 (gmt 0)

10+ Year Member



I'm using PHP DOM to read in an HTML page. What I would like to do is traverse through this HTML and associate each tag, id or class with its corresponding stylesheet attributes. For example: If I had a div with a class called "container", I could find the corresponding stylesheet container { color: red; }. I am able to do this example fairly easy, but stylesheets have many complexities in their hierarchy as well as the many ways to write them.

I was hoping there might be a class out there to do this? Perhaps something that works with PHP DOM that incorporates css files as well? Or maybe a project that someone knows about that I could gain research from or to point me in the right direction?

coopster

1:13 pm on Dec 5, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, gijoe.

More and more client-side development seems to be using the Sizzle engine. Perhaps that is something worth investigating?