Python Forum

Full Version: HTML Styling Not Working
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I am trying to embed an HTML table in an Outlook email using smtplib within Python. I have customized it but am having trouble modifying the rows. I wanted to have every other row colored but syntax like
tr:nth-child(odd){background-color: green}
is not working.

Snippet within Python code with customizations that work:

<html>
<head>
<style>
h2{text-align:center;font-family: arial;}
table{margin-left:auto;margin-right: auto;font-family:arial;font-size:12px;}
tbody th{border: 1px solid white;}
thead th{font-size:14px;color:white;background-color: #7682AA;}
tr:nth-child(odd){background-color: #CCE5FF;}
</style>
</head>
<body>
<h2> List</h2>

<table border="0" class="dataframe wide">
  <thead>
    <tr style="text-align: center;">
      <th></th>
      <th></th>
      <th></th>
      <th></th>
      <th></th>
    </tr>
    <tr>
      <th>Lobbyist Name</th>
      <th>Principal</th>
      <th>Employed On</th>
      <th>Issue Description</th>
      <th>Issue Status</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>ABRAHAM, MICHAEL</th>
      <th>Horizon Pharma Inc/ Horizon Therapeutics</th>
      <th>08/08/2019</th>
      <th>NONE</th>
      <th>Active</th>
    </tr>
    <tr>
      <th>KAUFMAN, GREGORY</th>
      <th>GOLDMAN SACHS & CO. LLC</th>
      <th>08/08/2019</th>
      <th>FINANCIAL PRODUCTS & SERVICES</th>
      <th>Active</th>
    </tr>
    <tr>
      <th>Sorge, Brian</th>
      <th>IRRAS</th>
      <th>08/08/2019</th>
      <th>SALES</th>
      <th>Active</th>
    </tr>
    <tr>
      <th>SCRUGGS, JEFFREY</th>
      <th>GOLDMAN SACHS & CO. LLC</th>
      <th>08/08/2019</th>
      <th>FINANCIAL PRODUCTS & SERVICES</th>
      <th>Active</th>
    </tr>
    <tr>
      <th>RILEY, RACHEL J</th>
      <th>Horizon Pharma Inc/ Horizon Therapeutics</th>
      <th>08/08/2019</th>
      <th>NONE</th>
      <th>Active</th>
    </tr>
    <tr>
      <th>NORONHA, CRYSTAL F</th>
      <th>Horizon Pharma Inc/ Horizon Therapeutics</th>
      <th>08/08/2019</th>
      <th>NONE</th>
      <th>Active</th>
    </tr>
    <tr>
      <th>ALLEN, JOSH</th>
      <th>Horizon Pharma Inc/ Horizon Therapeutics</th>
      <th>08/08/2019</th>
      <th>NONE</th>
      <th>Active</th>
    </tr>
  </tbody>
</table>
</body>
</html>
Thank you. I know this more HTML than Python, but if someone has any insight in how to go about this that would be great!
You can find if your client supports a particular css feature here