Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4383198
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:52:36+00:00 2026-05-21T12:52:36+00:00

I would like a library to create inlined CSS+HTML from .html and .css files

  • 0

I would like a library to create inlined CSS+HTML from .html and .css files or from an HTML file with tags in the head. I would prefer a PHP library if possible.

By inlined CSS I mean something like

<span style="font: bla bla bla">Hi There!</span>

versus

<style>  
    .greeting { font: bla bla bla; }  
</style>

I often need to put HTML into emails and this would simplify the process greatly.

If anyone is interested, my current solution (for stuff that isn’t restyled often) is to use the Smarty templating engine to create the document, and to assign the style=”” part to a variable inside the template.

Then I can use that variable in each tag (like <td {$td_style}> (FYI – {$variable} is how smarty variables are inserted into a template) and have it generate the appropriate email-friendly HTML.

However I want something that is more general, and for which I can just feed it some HTML and CSS rather than have to convert all of it to a smarty template.

Does anyone know if a library like this exists?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T12:52:36+00:00Added an answer on May 21, 2026 at 12:52 pm

    Although I don’t know of a library that handles this, if you’re set on PHP, you could do this fairly easily I would think by using CSSTidy to parse the CSS, and then using an XML parser (ideal if your code is well-formed–maybe SimpleXML or the DOM extension) or one of the PHP-based HTML parsers I see out there to parse the HTML, so you can alter the HTML via DOM methods according to CSS rules.

    If you don’t need it tied into a PHP process though, I recommend going with JavaScript for almost anything like this, since it can work in the client-side (and in different environments) and be a handy tool for anyone wishing to do this; you should be able to parse the CSS using http://glazman.org/JSCSSP/ and then using DOMParser() and the IE equivalent as needed (for XHTML) or use innerHTML, this htmlparser, or any other HTML Parsers.

    Btw, I know <style> works in emails since my add-on Color Source injects them to get syntax highlighting in emails, though I guess you were only saying it is more complicated for you to do it that way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Python's Imaging Library I want to create a PNG file. I would like
I'm working on a Java library and would like to remove some functions from
I would like to know the recommended library or procedure for dealing with multi-coloured
I have a library that I would like to license and distribute. I know
Is there a Bayesian filter library for .NET? I would like to setup a
I am currently working on a REST library for .net, and I would like
In C#, I am using a library that defines an enum. I would like
Would like to create a strong password in C++. Any suggestions? I assume it
I would like to test a string containing a path to a file for
I would like to create an ASP.Net page without all the codebehind and designer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.