I am working on an HTML file that I will use as both an attachment to an email and the basis for an HTML based email message that has a table with 13 columns.
I would like to have the columns auto size based on the contents so that columns with shorter headings and values do not take up as much space as longer valued columns. Right now I am seeing that all the columns are evenly sized.
Here is my current CSS and table code snippets
/* What it does: Stops Outlook from adding extra spacing to tables. */
table, td {
mso-table-lspace: 0pt !important;
mso-table-rspace: 0pt !important;
}
/* What it does: Fixes webkit padding issue. Fix for Yahoo mail table alignment bug. Applies table-layout to the first 2 tables then removes for anything nested deeper. */
table {
border-spacing: 0 !important;
border-collapse: collapse !important;
table-layout: fixed !important;
margin: 0 auto !important;
}
table table table {
table-layout: auto;
}
<table width="100%" border="1" style="font-size:10pt;table-layout: fixed;">
<thead style="background-color:#10163C;color:#FFFFFF">
<tr>
<th>Semester</th>
<th>Evaluation End Date<br/>(11:59 PM)</th>
<th>Days<br/>Remaining</th>
<th>Subject</th>
<th>Catalog</th>
<th>Section</th>
<th>Course Name</th>
<th>Level</th>
<th>Trait</th>
<th>Instructor</th>
<th>Responses</th>
<th>Enrollment</th>
<th>Response<br/>Rate</th>
</tr>
</thead>
<tbody>
<tr>
<td>Fall 2020</td>
<td>December 9, 2020</td>
<td>5</td>
<td>SUBJ</td>
<td>1234</td>
<td>MWE</td>
<td>Class_Long NAme Goes Here</td>
<td>UGRD</td>
<td>Online</td>
<td>Y Teacher</td>
<td>0</td>
<td>0</td>
<td>0.00%</td>
</tr>
</tbody>
In the example the Semester, Days Remaining, Subject, Catalog, Section, Level, Trait, Responses, Enrollment, Response Rate columns should be narrower as they have short values.
While the Evaluation End Date and Course Name should be wider as their values are longer.
One limitation is that I cannot use JavaScript/JQuery as I am using email to send these out.