Template style sheet [solved]

Solutions for other phpList version 2 users
Forum rules
Please do not ask questions here, this is for Solutions you have discovered or come across.

Template style sheet [solved]

Postby Guest » 7:35am, Wed 26 Nov, 2008

How can I define a style sheet for a template? I'd settle for being able to define the color of link text.
Guest
 

Postby H2B2 » 8:13am, Wed 26 Nov, 2008

Since many webmail providers are known to remove style declarations in the head part of HTML messages, it is generally recommended to use inline styles.

On the other hand, using inline styles goes with some limitations. For instance, you can't use an inline style for <a> tags (links), afaik.
A common workaround for this issue is to use javascript, e.g.:
<a href="http://www.somesite.com/" style="text-decoration: none;" onmouseover="this.style.color='#FF0000'" onmouseout="this.style.color='#330066'">Link:no decoration, hover will turn red, active will turn purple/dark blue</a>

Source

The trouble with javascript in messages, is that it will most likely increase their spam score. Its up to you to decide whether styling the links is worth taking that risk. Or run some tests to see if your messages still pass the spam filters.
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Postby Guest » 9:37am, Wed 26 Nov, 2008

I editd the code in sendmaillib and was able to get an embedded style sheet into the message. It's definitley there when I receive the message but it's no having any effect on the links. The code at the top of the message looks like this:

Code: Select all
<html><head>
        <meta>
        <title></title><style>a:link {color:"#336600"}</style></head><body>


Does that syntax look OK?

Pete
Guest
 

Postby H2B2 » 4:53pm, Wed 26 Nov, 2008

Not quite. You could try something like this instead:
Code: Select all
<style type="text/css">
a { color: #FFA500; text-decoration: none; }
a:hover { color: #FFD700;text-decoration: underline; }
a:active { color: #FF0000;text-decoration: none; }
</style>

Keep in mind that hardcoding styles in the phplist code means that all HTML messages will have that style. This will be problematic if you want to send different newsletters, each with their own specific styles.

Also, remember that style declarations in the message head part risk getting stripped by webmail providers.
As an alternative, you could try placing your style declaration at the start of the body part of your template. This may not be valid, but it is usually accepted and rendered by webmail providers and email clients.
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Postby Guest » 7:25pm, Wed 26 Nov, 2008

Excellent, thank you. I inserted the style definition immediately before the tag in my template and all worked fine, at least in my mail reader (OSX Mail).

Off topic, does anyone understand why my last message was blocked because it contained one of those things that users click on to get to a web site when there was nothing resembling one in the message? I can't use the real term because then this post will be blocked.

That caused me to post some dummy messages to get around the 10 post limitation on those things, which in turn resulted in an email smack on the wrist for spamming!

Leaving aside for the moment the issue of whether anyone is less likely to do some hacking on their 11th and subsequent posts than on their 1st through 10th, if rules like that are to be enforced, the least that should be done is to correctly identify the offending messages.


OK, end of rant. I'm getting good info from the forum but stuff like this is frustrating when you're trying to get something to work.

Pete
Guest
 


Return to Answers, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 1 guest