Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HTML Styling Not Working
#1
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!
Reply
#2
You can find if your client supports a particular css feature here
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  HTML multi select HTML listbox with Flask/Python rfeyer 0 4,617 Mar-14-2021, 12:23 PM
Last Post: rfeyer
  Parsing html page and working with checkbox (on a captcha) straannick 17 11,260 Feb-04-2021, 02:54 PM
Last Post: snippsat
  Python3 + BeautifulSoup4 + lxml (HTML -> CSV) - How to loop to next HTML/new CSV Row BrandonKastning 0 2,353 Mar-22-2020, 06:10 AM
Last Post: BrandonKastning

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020