0

I am trying to write a php script that will take find the path of a webpage or a url, and convert the css from the server or local folder to inline code. I've looked pretty much all over the internet and looked for many solutions that could help me do this and done helped so far.

I have several <div>'s in my page all linking to a css code called general.css
For e.g.

<div class="sys_main_logo" style="">
		
<div class="sys_ml">
            
<div class="sys_ml_wrapper">

I want it to be able to convert to the properties of the css it's linked to to inline code
for e.g.

<div style="position: relative; z-index: 56; background-color: #f4f4f4;>

Is this possible to write, can somebody assist me with this please? Thanks

2
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by pritaeas
0

Anything is possible. In it's most basic version a simple replace will do. Don't be mislead, CSS is a cascading style and can inherit from it's parent or another class. That makes it much more difficult.

First you'll need a script to parse a css file, so you can match tags, id's and classes.

I think the best way for you to start, is to limit the scope of what you allow in your html and css, and work from there.

0

It's because i'm trying to send the webpage as an e-mail, and i will have future webpages to send as e-mails as well so i need a PHP code that will take out the <a href> links and turn all css links into inline style code. I already have a code where it removes all <a href> links. Can i have help with this please?

0

Wouldn't it be easier to make an email template, as not every email client supports every css ?

Anyway, start with a parser for css. Something that opens the css file and cuts it to pieces.

0

Wouldn't it be easier to make an email template, as not every email client supports every css ?

Anyway, start with a parser for css. Something that opens the css file and cuts it to pieces.

Can you guide me through doing that? Because i am brand new to PHP

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.