Jump to content

Using Php To Convert Css To Inline Style


IanArcher

Recommended Posts

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.cssFor 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 codefor 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

Link to comment
Share on other sites

i am not sure why you need that to do like this? it is always best practise to avoid inline styling if you are trying to reduce the request header you can include the css stylesheet in server side in <head> in <style> tag and the send it to browser. other than that you could done that you need to parse the css stylesheet and then applying the rearrange the tags according to that. it is likely writing a parser itself which will also pull some server resource which seems unusual from this point.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?
My experiences is what HTML emails are limited to the support of HTML tags and the support of tags are widely spread between different email clients. So either you have a very simple web page or you may want to rethink your idea of sending your web page to your visitors email clients.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...