Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7435307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:03:11+00:00 2026-05-29T10:03:11+00:00

I just had this html email figured out and now i need to style

  • 0

I just had this html email figured out and now i need to style it so that i can get a space between these 2 columns on my table here is my code:

    var html = new XDocument(
 new XElement("html",
     new XElement("body",
         new XElement("h2", "Your entire inventory:"),
         new XElement("table",
             new XElement("tr",
                 new XElement("th", "Product"),

                 new XElement("th", "Quantity")),
                    new XElement("tr",
                 from item in prodList
                 select new XElement("td", item.ProductName, new XElement("td", item.Quantity), new XElement("tr")))
                 ))));

This is the output i get:

Your entire inventory:

                Product                    Quantity
Nissin rich & savory chicken bw - 6 pack  5
The Zombie Survival Guide                 3
Maruchan Ramen Noodle Soup                5
Generic Tomatoes, Whole                   2

So i need to figure out how to put style in the tags to get the padding/border etc in the email

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:03:12+00:00Added an answer on May 29, 2026 at 10:03 am

    Your XElement structure is fairly broken (you’re defining tr elements within td elements within other td elements); it’s rather unpredictable how a browser would render the result. Here is how it looks:

    <html>
      <body>
        <h2>Your entire inventory:</h2>
        <table>
          <tr>
            <th>Product</th>
            <th>Quantity</th>
          </tr>
          <tr>
            <td>Nissin rich &amp; savory chicken bw - 6 pack<td>5</td><tr /></td>
            <td>The Zombie Survival Guide<td>3</td><tr /></td>
            <td>Maruchan Ramen Noodle Soup<td>5</td><tr /></td>
            <td>Generic Tomatoes, Whole<td>2</td><tr /></td>
          </tr>
        </table>
      </body>
    </html>
    

    To start off, you should fix your HTML generation code (see below).

    Since you’re intending to use your HTML in emails, you should preferably steer clear of embedded style sheets (despite their appeal for avoiding code repetition). Some email (web)clients, most notably Gmail, simply ignore embedded style sheets (refer to Using CSS and HTML in Email Newsletters). In most cases, it’s safer to use inline styles for HTML emails.

    To introduce some spacing between your two columns, you could define an line style="padding-right:50px;" attribute on all cells within the left column; this would ensure that there are 50 pixels of whitespace between the longest product name and the quantities column.

    var html = new XDocument(
        new XElement("html",
            new XElement("body",
                new XElement("h2", "Your entire inventory:"),
                new XElement("table",
                    new XElement("tr",
                    new XElement("th", "Product", 
                        new XAttribute("style", "padding-right:50px;")),
                    new XElement("th", "Quantity")),
                from item in prodList
                select new XElement("tr",
                    new XElement("td", item.ProductName, 
                        new XAttribute("style", "padding-right:50px;")),
                    new XElement("td", item.Quantity))))));
    

    The above code would generate:

    <html>
      <body>
        <h2>Your entire inventory:</h2>
        <table>
          <tr>
            <th style="padding-right:50px;">Product</th>
            <th>Quantity</th>
          </tr>
          <tr>
            <td style="padding-right:50px;">Nissin rich &amp; savory chicken bw - 6 pack</td>
            <td>5</td>
          </tr>
          <tr>
            <td style="padding-right:50px;">The Zombie Survival Guide</td>
            <td>3</td>
          </tr>
          <tr>
            <td style="padding-right:50px;">Maruchan Ramen Noodle Soup</td>
            <td>5</td>
          </tr>
          <tr>
            <td style="padding-right:50px;">Generic Tomatoes, Whole</td>
            <td>2</td>
          </tr>
        </table>
      </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I thought I had this figured out but it turns out I'm just deleting
I was just reading this article and it mentions that some organization had an
I've just found out that a spammer is sending email from our domain name,
I had this embedded map working just fine and now suddenly it just shows
I'm sure someone's had this problem before but I can't figure it out because
Had finally gotten all the bugs out of this and now they said Oh,
Seems like just yesterday I had this same problem with Play! v1. After trying
Hey This is my login script, using PHP5 and MYSQLi, I just had help
So just this week I had the opportunity to re-build my development machine and
Just wondering if you had any thoughts on this problem. I want to make

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.