Is there a way to position the text within an email body at the center using SendGrid?

I've been working on creating an email newsletter template using SendGrid, and I've run into a formatting issue where the content doesn't align properly in the email body. The image below shows how it's appearing incorrectly. Does anyone have tips on centering the content within the newsletter?

Edit 1: The problem seems to be specific to Outlook

<style type="text/css">
    body {
      min-width: 100%;
      margin: 0;
      padding: 0;
      -webkit-font-smoothing: antialiased;
      font-family: Trebuchet MS;
    }
    span {
      color:#808080;
      font-size:12px;
    }
    img {
      display: inline-block;
      max-width: 100%;
      max-height: 100%;
    }
    table {
        border-collapse: collapse;
        }

  </style>

<!--Main Container-->
<table border="" cellpadding="0" cellspacing="0" width="100%" class="wrapper">
<tbody>
  <tr>
    <td valign="top" width="600">
        <!--First Table-->
                <table border="0" cellpadding="0" cellspacing="0" class="devicewidth">
                    <tbody>
                        <tr>
                            <td valign="top">
                              <!--Content-->
                            </td>
                            <td valign="top">
                              <!--Content-->
                            </td>
                            <td valign="top">
                              <!--Content-->
                            </td>
                            <td valign="top">
                              <!--Content-->
                            </td>
                            <td valign="top">
                              <!--Content-->
                            </td>
                            <td valign="top">
                              <!--Content-->
                            </td>
                      </tr>
                  </tbody>
                </table>
    </td>
  </tr>
</tbody>
</table>
<!--End of Main Container-->

False image

Answer №1

It should work with all newsletter and template systems, such as Mailchimp. Your code just needs to include a 'vertical center' for alignment.

Check out the snippet below for an example:

<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%" id="backgroundTable" style="background-color:red;height:200px;">
<tr>
    <!-- THIS <td> element needs align center!! -->
    <td align="center" valign="top" >

      <table border="0" cellpadding="0" cellspacing="0" width="200" class="templateContainer" style="background-color:white;height:100%;">
<tr>
<td>
           content goes here
         </td>
       </tr>
     </table>
   </td>
   </tr>
</table>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Incorporating HTML with ng-binds through transclusion

I have been developing an angular directive to enhance the functionality of ng-table by adding filtering and exporting features. The main goal is to make this directive reusable for multiple tables, which requires the <td> elements to be dynamic. To ...

Using Bootstrap 3 with ResponsiveSlides.js

I've been struggling to center the ResponsiveSlides slider within a bootstrap column. Despite resizing my large images to 80% in the CSS, they still refuse to align properly since they're no longer fitting the entire screen at 100%. Can someone l ...

Is there a way to adjust the transparency of specific text when clicking on a different div?

How can I display a line of text when the "Contact Us" button is clicked on a practice website, similar to this: I have set the current opacity of the submit message to 0 so it is hidden, but is there a way to change its opacity to 1 when the submit link ...

Find the mean of two values entered by the user using JavaScript

I'm sorry for asking such a basic question, but I've been struggling to get this code to work for quite some time now. I'm ashamed to admit how long I've spent trying to figure it out and how many related StackOverflow questions I ...

Prevent double tap selection

At times, I enable the user to click on the <li> or <span class="icon"> elements, but if they happen to click twice, it causes a bit of chaos and spreads the blue selection all over :/ To address this issue, I have come up with two solutions: ...

Using AngularJS ng-repeat to pass href links

I am facing an issue with displaying hyperlinks in a list of messages obtained from server response using AngularJS. $scope.messages = [] When a button is clicked, the content of a text area is added to the array using ng-click method. This message is th ...

Conceal header and footer bar in Jquery Datatable theme

I need assistance in removing the header/footer bar from this table Here is a visual representation of what I am looking to remove: The jQuery code for this table: $(document).ready(function() { var oTable = $('#tableSmooth').dataTable({ ...

Trouble encountered with card flip style login form in Vue.js, as the card is not maintaining its position properly during transition animations

Need help styling a login/signup component in Vue.js where flipping between the two cards isn't working smoothly. The transition is causing one card to move down and right while the other comes in from the bottom right. It's hard to explain the i ...

I aim to place my :after content in mobile view or lower resolutions

I have a testimonial section built with HTML and CSS. You can view the demo on JSFIDDLE HERE. In the mobile view, I am facing an issue where the ":after" content is not aligning properly or appears misplaced. I'm looking for ideas to ensure that it re ...

Customize Your Chrome Experience: Inject an Element to Open a Hidden HTML Page within the Extension

I am currently working on a Chrome extension and I would like to add a link tag into an object, which will then direct the user to an about page stored within the extension itself. Is there a way to achieve this? Below is the code from my content.js file: ...

I'm attempting to make this script function correctly when an image is loaded

Can anyone help me figure out how to make this script function on image load instead of onclick? I came across the script on stackoverflow, but it was originally set up for onclick. I want it to work for onload or .load HTML====== <div id="contai ...

Footer overlapping occurs on a single page

My webpage is having an issue where the footer is overlapping. It seems to be fine on all other pages except for this one. I would prefer not to make any changes to the footer since it's working correctly on other pages. Is there a way to adjust the C ...

How to create a dynamic background color animation in jQuery similar to a progress bar animation

I have a container with text content (for example: My Name) and it is displayed in a RED background color along with a button. What I am looking for : When the button is clicked, I want to change the background color of the container from RED to BLUE, si ...

Set the CSS/HTML to make two child elements occupy 50% of the height of the parent container div

This task seems deceptively simple, yet I am struggling to find a straightforward solution. Language: (HTML) <div class="col-6-12 subcontent-outer"> <div class="subcontent"> <h1>Header</h1> ...

Preventing Form Submission from Redirecting to the Top in an HTML Document with PHP

Recently, I integrated a php form into my html code and changed the file from index.html to index.php. The contact form is functioning perfectly and sending all information as expected. However, after submitting the form, users are receiving the message "T ...

Learn how to incorporate a YouTube video into your website without using Flash or JavaScript by utilizing a popup window

I am in search of assistance with coding for my website to include a video popup feature featuring a YouTube video. I prefer the use of HTML5 rather than Flash or JavaScript. Unfortunately, I have been unable to locate any suitable code examples. While I ...

Explain the usage of bootstrap col-md-** without resorting to inline styling

Consider the example below <html> <head> </head> <body> <div class="col-xs-12 col-sm-12 offset-md-4 col-md-4 offset-lg-4 col-lg-4"></div> <div class="col-xs-12 col-sm-12 offset-md-4 col-md-4 offset-lg-4 col-lg- ...

Use the jQuery library to detect scrolling and toggle the CSS class between 'selected' and

I am trying to dynamically add the "selected" class to a[href] when a specific DIV comes into view while scrolling. However, I want to remove this class completely once the DIV has been scrolled past. const links = $(".cd-faq-categories li a"); // Find al ...

Displaying PHP processes within a DIV instantly using JQUERY, without the need to wait for them to complete

I currently have two scripts that I am working with. My goal is to use jQuery to send a form to a PHP file and display the process in a DIV. However, there is a delay in showing the progress until it completes, which can sometimes take a few seconds, caus ...

Is it possible to nest a section tag within an anchor tag?

Is it possible to nest a section tag within an a tag? For example: <a href="mylink"> <section class=mysection> <h2>my headline</h2> <p>my paragraph</p> </section> </a> Thank you for your help ...