Application to Turn External CSS to Inline
December 11, 2006 11:56 AM   Subscribe

Is there an online application that will take an HTML page with an external stylesheet and make the styles inline? e.g. style="color:#000000"

I run into this a lot for creating newsletters, and would love to have something that could parse it all without me having to do it manually.
posted by destro to Computers & Internet (8 answers total)
 
Constant Contact does this, more or less, with their current system for sending out newsletters, although you're limited to class names in terms of css selectors.
posted by weston at 12:01 PM on December 11, 2006


i can think of a way to do this using a few perl modules

but the programmer inside me tempts the question (as always) why? maybe there's a better way to do what you're actually trying to do, but doesn't involve requiring this somewhat arcane step

with that said, feel free to message me if you need this enough to be willing to spend some $$...
posted by qbxk at 1:09 PM on December 11, 2006


why can't you embed the stylesheet into the page? you can just cut and paste the sheet between a couple of style tags in your head section.
posted by mrg at 1:34 PM on December 11, 2006


mrg's suggestion will work for some mail readers. Other mail clients (especially some web mail readers, including Yahoo and Hotmail IIRC) tend to strip out or ignore everything that's not in the body.
posted by weston at 2:09 PM on December 11, 2006


mrgs suggestion would be by far the easiest and best solution, unless there's some reason you can't do it.
He's talking about doing this


<head>
<style type="text/css">

... paste the contents of your css file in here

</style>
</head>

posted by Hildago at 2:19 PM on December 11, 2006


Gmail doesn't support any sort of embedded style code except for inline. Hidalgo's solution works for most of the rest of them.

Given the current state of email readers, many pro email designers are sticking to table-based layouts and simple graphics. There are many inconsistencies among email clients, and a lot of security concerns, and the best thing to do is to keep things simple and use the most tried and true methods of display/presentation (at least inline CSS styles are universally supported, which is a good thing. No FONT tags).

The only way I know to convert styles is manually. I'm hoping someone has a tool to do an automatic conversion as you're suggesting.
posted by brianvan at 3:10 PM on December 11, 2006


Response by poster: Yeah, inline CSS is a necessity. I may look to qbxk and some perl routines, but otherwise it's a manual life for me.
posted by destro at 8:55 PM on December 11, 2006


brianvan, I'm interested in something like this as well. it comes up seldom enough that i've just done it manually though.

but i can see that it would be really useful to put together a web app that has two big textareas -- one for css, one for html, and munge the selectors together.

seems like a job for php5's nice dom selector tools to do replaces on the appropriate tags.

for the cascade though, that's tricky, as some styles will supercede others.

(for a minute, i wanted to work on this, but in reality, i can see it's going to require a full css parser and html parser as well).
posted by artlung at 11:15 PM on December 11, 2006


« Older What's the bestest way to self-publish?   |   Recommend an LCD monitor. Newer »
This thread is closed to new comments.