artist has asked for the
wisdom of the Perl Monks concerning the following question:

Dear Monks
I need to put the CSS data into given HTML file so that CSS files (different for Netscape and IE) are not required anymore. Manually it takes so much time and gets little unclean, so I need some suggestions. I looked at CSS modules on CPAN, but not sure that which module would be useful for this purpose.

Thanks.

Update: I know it is reverse engineering, however it is part of the job. The HTML formatted data is used by some existing perl programs rather than directly displaying in the browser.

Update2: Perhaps I should have mentioned earlier:
Any solution which doesn't alter the CSS style format won't work. Becuase I have to put this embeded HTML in the existing perl program as part of the bigger HTML display ie..(using templates for header etc..)

Out of curiosity, why do you want to do this. From my readings and observations, having the CSS in a seperate file is a big plus. The CSS file will be cached by the browser. The caching can result in significant bandwidth savings. I would be interested in hearing the reasons for bringing it back into the HTML file.

I'm not sure I'm interpretting you correctly, but if you're trying to put styling back into the HTML tags, you're not going to be able to keep the browser-specific stuff.
Can you give us more information about what your end goal is? There's always more than one way to do it.

Unless you are having to support Netscape 4, CSS should be identical for all browsers. Since older browsers constitute less than 1% of the traffic to my sites, I've forgotten all about the browser wars.

It sounds like you are being asked to do this from above. Now would be a very good idea to suggest some of the strategies put forward by Jeffrey Zeldman on designing with web standards.

If you are using HTML as a machine-readable data format, how will any presentational style information be used?

[OT] Oh...I wish. Maybe when it snows in hell. I spend my days building sites with CSS and XHTML (no tables, W3 validated) and the hacks that are necessary to get any given page to work across the board is almost overwhelming. Both Win and Mac IE's are the worst. Mozilla, Netscape and Safari are the best. It's a like defusing a bomb all day long.

It really would be more beneficial for you to keep the external CSS file. It saves so much more time when you want to make a quick update on the appearance of your site. Also, unless I have misunderstood what you are trying to do, CSS is what you will want to stick to if you would like to conform to XHTML standards, because most of the formatting tags (such as the bold, italic, underline, and center tags to name a few) have been dpreciated.

Macromedia Dreamweaver 3 had an option for doing this. I don't have it installed right now so I can't tell you more but the option was there to allow you to produce code for non CSS compliant browsers.

After reading your second Update, I wonder if you might be able to use Html::Template, or are using it. If that's so you might look at Re: HTML::Template Tutorial which shows how to include css with Html::Template, the second working on older browsers because of the comments.

"Cogito cogito ergo cogito sum - I think that I think, therefore I think that I am." Ambrose Bierce

When putting a smiley right before a closing parenthesis, do you:

Use two parentheses: (Like this: :) )
Use one parenthesis: (Like this: :)
Reverse direction of the smiley: (Like this: (: )
Use angle/square brackets instead of parentheses
Use C-style commenting to set the smiley off from the closing parenthesis
Make the smiley a dunce: (:>
I disapprove of emoticons
Other