default font when sending html email with php, viewing in outlook

10,218

Solution 1

Why don't you simply wrap the whole thing in a div with the style you want?

<div style="font-family: Arial, Helvetica, sans-serif;">
...
</div>

Solution 2

Many email clients IGNORE COMPLETELY any <style> blocks in your code. You have to style each element individually, then test it using an email testing service (some are free).

Google Results

Share:
10,218
kkuni
Author by

kkuni

Updated on July 16, 2022

Comments

  • kkuni
    kkuni almost 2 years

    I am trying to figure out a way to specify a default font for my outgoing HTML emails. The reason for this is because outlook's default font is in Times New Roman, and I would like it to be in Arial instead.

    I tried doing <body style="font-family: Arial, Helvetica, sans-serif;">

    but a < a href> tag within a < table> in my email, for example, still shows up in Times in Outlook.

    I also tried doing a global css declaration, like

    <style> 
    body {font-family:Arial, Helvetica, sans-serif; }
    </style>
    

    and this didn't do it as well.

    Is there a way to specify a default font for my HTML, without having to hardcode the font face in each link?

    This will work obviously in outlook < a href=# style="font-family: Arial, Helvetica, sans-serif;">

  • kkuni
    kkuni almost 12 years
    Thanks for the input wookai.Yes, I am already doing this. But it wouldn't handle a case where the link is within a table. updating my post to reflect this.
  • kkuni
    kkuni almost 12 years
    Yes I have come to realize this ... is there then no way to specify a "default font" in html emails ? The content is generated through a wysiwyg editor by users. Do I have to go through every html element with regex and attach a style='font-family: ...' if it didn't have a explicit font-face declaration ?
  • Matt
    Matt almost 12 years
    @kkuni welcome to the wonderful world of html email! Get used to hours of work just to get one paragraph to look right in every client.
  • kkuni
    kkuni almost 12 years
    yeah, outlook seems to be the pickiest when deciding which css to apply. Also, many of the web mail (gmail, yahoo mail ...) usually have Arial as their default font ... not quite sure why outlook went with Times New Roman.
  • Matt
    Matt almost 12 years
    @kkuni just wait until you see what it looks like in Lotus notes! haha, have fun with THAT one. And (seriously) good luck.
  • kkuni
    kkuni almost 12 years
    thanks Matt, I figure I might need it. You think there would be some sort of global font declaration that will be respected by all email clients, but I guess not