Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2007
    Location
    Los Angeles
    Posts
    545
    Thanks
    81
    Thanked 5 Times in 5 Posts

    Can I change margins in HTML emails?

    I'm using PHP to compose an html email and I'd like to add the following css statement to control the p margin spacing when the recipient looks at the email:

    Code:
    <style type="text/css">p {margin:0; padding: 0;}</style>
    Right now, the vertical spacing is too much and this css statement reduces it nicely.

    I'm not sure where to insert this css statement into my php script that constructs the html email?
    RalphF
    Business Text Messaging Services
    https://www.MobileTextingService.com

  • #2
    Regular Coder
    Join Date
    Jan 2008
    Location
    Geneva, Switzerland
    Posts
    413
    Thanks
    12
    Thanked 29 Times in 29 Posts
    Then why don't you post your code?
    Chuck Norris counted to infinity.
    Twice.

  • #3
    Regular Coder
    Join Date
    Jun 2007
    Location
    Los Angeles
    Posts
    545
    Thanks
    81
    Thanked 5 Times in 5 Posts
    My php script is a rather long file. This is a snippet of where I create the headers. When I view the sent email in my gmail account, I don't see any change in the vertical spacing of the <p tags.

    PHP Code:
    $headers  'MIME-Version: 1.0' "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";
    $headers .= '<style type="text/css">p {margin:0; padding: 0;}</style>' "\r\n"
    RalphF
    Business Text Messaging Services
    https://www.MobileTextingService.com

  • #4
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    Review these lists and articles for a possible problem facing you:

    http://css-tricks.com/133-using-css-...he-real-story/

    http://www.campaignmonitor.com/css/

    HTML email display will depend largely on which email client the message is being viewed in. Things that work perfectly in one place won't register AT ALL in others. For example, <style> tags themselves are not honored at all in gmail, whether they are in the head or the body of the message. Hotmail won't honor all margins.

    Things are complex. It might be more beneficial for you to provide us with the generated HTML code that is being sent as email rather than giving us the PHP. That will help us to see any formatting issues that may be present in the final product, which is where your trouble really is.
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •