Integrate CSS in HTML

-1

I have an HTML that I intend to send by mail. Due to this, I can not put relative routes to the CSS. Are there ways to integrate the CSS into the HTML code, that is, have everything in the same file, without the need to include the CSS separately? (I've tried the link library but it has not worked for me.

I have also done what was suggested in this answer but it has not worked either: link

    
asked by user91042 20.06.2018 в 13:04
source

4 answers

0

Definitely the best solution for this problem is to use the <style></style> tags within the <body> , now that if the styles are not many you can do it directly in the html tags <h1 style="color: blue;">Hola</h1>

I hope you answer, greetings.

    
answered by 20.06.2018 / 16:47
source
1

You can put it internal

<!DOCTYPE html>
<html>
<head>
<style>
body {background-color: powderblue;}
h1   {color: blue;}
p    {color: red;}
</style>
</head>
<body>

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

</body>
</html> 

or use the style attributes of html

 <h1 style="color:blue;">This is a Blue Heading</h1> 

Source

    
answered by 20.06.2018 в 13:24
0

In the headers you probably have Content-type: text / plain;

Review this example:

<?php 
    $body = "<html>\n"; 
    $body .= "<body style=\"font-family:Verdana; font-size:12px; \">\n"; 
    $body = $message; 
    $body .= "</body>\n"; 
    $body .= "</html>\n"; 

    $headers .= 'MIME-Version: 1.0' . "\n"; 
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 

    return mail($recipient, $subject, $message, $headers); 
?>

And make sure HTML is active in $ mail :

$mail->IsHTML(true);
    
answered by 21.06.2018 в 16:31
0

the < style > tag is deleted by many email managers, if it's an email you have no choice but to put the styles online.

    
answered by 21.06.2018 в 15:32