Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the best way to process external CSS stylesheets and inject into inline CSS elements?
    text
    copied!<p>I am going to be writing a PHP mailing list system. Ideally, I would like for the templates styles to be easy to manage. In my current system, I have the styles all hardcoded in the template like this:</p> <pre><code>&lt;a href="http://blah/blah/blah" style="color: #a8a8a8;"&gt;click here&lt;/a&gt; </code></pre> <p>This works alright until the person managing the template decides that they want to change the color of the link text. What I'd really like is to have something process the HTML and style definitions and output the HTML with the appropriate HTML.</p> <p>What I am hoping for is something that will take the following input:</p> <pre><code>&lt;style type="text/css"&gt; a { color: #a8a8a8; } &lt;/style&gt; &lt;a href="http://blah/blah/blah"&gt;click here&lt;/a&gt; </code></pre> <p>... and generate...</p> <pre><code>&lt;a href="http://blah/blah/blah" style="color: #a8a8a8;"&gt;click here&lt;/a&gt; </code></pre> <p>... such that if the stylesheet is updated, the "rendered" HTML will all reflect these changes.</p> <p>It would be great if this could be used with either inline <code>&lt;style&gt;&lt;/style&gt;</code> tags or by using external CSS <code>links</code>.</p> <p>I'm doing this because my experience has shown that some (most? all?) of the webmail clients I have used do not appear to honor style information, external or otherwise. If I've missed something here and there is a more simple way to do this, would love to hear about those suggestions too. :)</p> <p><strong>EDIT</strong> I did some more queries and found another Stackoverflow question that <a href="https://stackoverflow.com/questions/260605/php-css-selector-library">discusses CSS Selectors</a> and I think I will try to use something like phpQuery to handle this.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload