Web Analytics Made Easy -
StatCounter Can I change margins in HTML emails? - CodingForum

Announcement

Collapse
No announcement yet.

Can I change margins in HTML emails?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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
    Then why don't you post your code?
    Chuck Norris counted to infinity.
    Twice.

    Comment


    • #3
      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

      Comment


      • #4
        Review these lists and articles for a possible problem facing you:



        A complete breakdown of the CSS support for the most popular mobile, web and desktop email clients on the planet.


        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

        Comment

        Working...
        X
        😀
        🥰
        🤢
        😎
        😡
        👍
        👎