Why Does <th> Not Span 100% Width of the Row? HTML CSS - html

I've created a basic HTML table yet I can't seem to get the top <th> element to span 100% width of it's parent <tr> element (and ultimately the <table> element).
.my-card-table {
width: 100%;
border: 1px solid #D9D7D6;
table-layout: fixed!important;
}
.table-top-heading {
display: block;
text-align: center;
}
.my-card-table-heading {
background-color: #E9E9E9!important;
font-family: "Proxima Nova Regular";
color: #000000;
font-size: 1rem;
padding: 10px 5px 10px 5px;
}
.my-card-table-heading-inner {
background-color: #E9E9E9!important;
font-family: "Proxima Nova Regular";
color: #000000;
font-size: 1rem;
text-align: left;
padding: 10px 0 10px 30px
}
.my-card-table-row-grey {
background-color: #F2F3F3!important;
padding: 10px!important;
}
.my-card-table-row-white {
background-color: #ffffff!important;
padding: 10px!important;
}
..my-table-td {
text-align: left;
padding-left: 30px;
}
.my-card-link {
color: #0e5b8b;
}
.my-card-link:hover {
font-family: "Proxima Nova Bold";
color: #0e5b8b;
}
.my-card-link-2 {
color: #212529;
}
<table class="my-card-table">
<tr class="table-top-heading">
<th class="table-top-heading-header">HelloWorld</th>
</tr>
<tr class="my-card-table-heading">
<th class="my-card-table-heading-inner">Teachers</th>
<th class="my-card-table-heading-inner">School</th>
<th class="my-card-table-heading-inner">Status</th>
</tr>
<tr class="my-card-table-row-grey">
<td class="my-table-td">Teacher 1</td>
<td class="my-table-td">Long Grove</td>
<td class="my-table-td">Logged In</td>
</tr>
<tr class="my-card-table-row-white">
<td class="my-table-td">Teacher 2</td>
<td class="my-table-td">Long Grove</td>
<td class="my-table-td">Logged In</td>
</tr>
<tr class="my-card-table-row-grey">
<td class="my-table-td">Teacher 3</td>
<td class="my-table-td">Lincolnshire</td>
<td class="my-table-td">Logged In</td>
</tr>
<tr class="my-card-table-row-white">
<td class="my-table-td">Teacher 4</td>
<td class="my-table-td">Buffalo Grove</td>
<td class="my-table-td">Logged In</td>
</tr>
<tr class="my-card-table-row-grey">
<td class="my-table-td">Teacher 5</td>
<td class="my-table-td">Kenilworth</td>
<td class="my-table-td">Not Logged In</td>
</tr>
<tr class="my-card-table-row-white">
<td class="my-table-td">Teacher 6</td>
<td class="my-table-td">Schaumburg</td>
<td class="my-table-td">Not Logged In</td>
</tr>
<tr class="my-card-table-row-grey">
<td class="my-table-td">Teacher 7</td>
<td class="my-table-td">Schaumburg</td>
<td class="my-table-td">Not Logged In</td>
</tr>
</table>
So when you run that code snippet ^ what I want to see is 'helloWorld' centered above the 'Teachers, School, Status' row. I'm not sure why it only seems to be expanding a quarter of the table width - does it have to do with the table-layout: fixed style that I've set on the <table> element?
Link to JSFiddle

Two things:
1.) You need to add colspan="3" as an attribute to that thto make it span all three columns of that table.
2.) You should not use display: block for a table element, regardless if that's td, th, tr or whatever. The display setting of the th by default is table-cell- just leave that as it is, otherwise the table won't be a "real table" in the end (i.e. the cells loose their automatic way of aligning and adjusting themselves).
.my-card-table {
width: 100%;
border: 1px solid #D9D7D6;
table-layout: fixed!important;
}
.table-top-heading {
text-align: center;
}
.my-card-table-heading {
background-color: #E9E9E9!important;
font-family: "Proxima Nova Regular";
color: #000000;
font-size: 1rem;
padding: 10px 5px 10px 5px;
}
.my-card-table-heading-inner {
background-color: #E9E9E9!important;
font-family: "Proxima Nova Regular";
color: #000000;
font-size: 1rem;
text-align: left;
padding: 10px 0 10px 30px
}
.my-card-table-row-grey {
background-color: #F2F3F3!important;
padding: 10px!important;
}
.my-card-table-row-white {
background-color: #ffffff!important;
padding: 10px!important;
}
..my-table-td {
text-align: left;
padding-left: 30px;
}
.my-card-link {
color: #0e5b8b;
}
.my-card-link:hover {
font-family: "Proxima Nova Bold";
color: #0e5b8b;
}
.my-card-link-2 {
color: #212529;
}
<table class="my-card-table">
<tr class="table-top-heading">
<th class="table-top-heading-header" colspan="3">HelloWorld</th>
</tr>
<tr class="my-card-table-heading">
<th class="my-card-table-heading-inner">Teachers</th>
<th class="my-card-table-heading-inner">School</th>
<th class="my-card-table-heading-inner">Status</th>
</tr>
<tr class="my-card-table-row-grey">
<td class="my-table-td">Teacher 1</td>
<td class="my-table-td">Long Grove</td>
<td class="my-table-td">Logged In</td>
</tr>
<tr class="my-card-table-row-white">
<td class="my-table-td">Teacher 2</td>
<td class="my-table-td">Long Grove</td>
<td class="my-table-td">Logged In</td>
</tr>
<tr class="my-card-table-row-grey">
<td class="my-table-td">Teacher 3</td>
<td class="my-table-td">Lincolnshire</td>
<td class="my-table-td">Logged In</td>
</tr>
<tr class="my-card-table-row-white">
<td class="my-table-td">Teacher 4</td>
<td class="my-table-td">Buffalo Grove</td>
<td class="my-table-td">Logged In</td>
</tr>
<tr class="my-card-table-row-grey">
<td class="my-table-td">Teacher 5</td>
<td class="my-table-td">Kenilworth</td>
<td class="my-table-td">Not Logged In</td>
</tr>
<tr class="my-card-table-row-white">
<td class="my-table-td">Teacher 6</td>
<td class="my-table-td">Schaumburg</td>
<td class="my-table-td">Not Logged In</td>
</tr>
<tr class="my-card-table-row-grey">
<td class="my-table-td">Teacher 7</td>
<td class="my-table-td">Schaumburg</td>
<td class="my-table-td">Not Logged In</td>
</tr>
</table>

You can set your ".my-card-table" and ".table-top-heading" to {display:flex}, and your ".table-top-heading-header" to {width:100%; text-align: center}.
You also had an extra (.) on your (my-table-td ) class.
Here's a working solution ;)
.my-card-table {
width: 100%;
border: 1px solid #D9D7D6;
display: flex;
}
.table-top-heading {
width: 100%;
display: flex;
}
.table-top-heading-header {
width: 100%;
text-align: center;
}
.my-card-table-heading {
background-color: #E9E9E9!important;
font-family: "Proxima Nova Regular";
color: #000000;
font-size: 1rem;
padding: 10px 5px 10px 5px;
}
.my-card-table-heading-inner {
background-color: #E9E9E9!important;
font-family: "Proxima Nova Regular";
color: #000000;
font-size: 1rem;
text-align: left;
padding: 10px 30px
}
.my-card-table-row-grey {
background-color: #F2F3F3!important;
padding: 10px!important;
}
.my-card-table-row-white {
background-color: #ffffff!important;
padding: 10px!important;
}
.my-table-td {
text-align: left;
padding-left: 30px;
}
.my-card-link {
color: #0e5b8b;
}
.my-card-link:hover {
font-family: "Proxima Nova Bold";
color: #0e5b8b;
}
.my-card-link-2 {
color: #212529;
}
<table class="my-card-table">
<tr class="table-top-heading">
<th class="table-top-heading-header">HelloWorld</th>
</tr>
<tr class="my-card-table-heading">
<th class="my-card-table-heading-inner">Teachers</th>
<th class="my-card-table-heading-inner">School</th>
<th class="my-card-table-heading-inner">Status</th>
</tr>
<tr class="my-card-table-row-grey">
<td class="my-table-td">Teacher 1</td>
<td class="my-table-td">Long Grove</td>
<td class="my-table-td">Logged In</td>
</tr>
<tr class="my-card-table-row-white">
<td class="my-table-td">Teacher 2</td>
<td class="my-table-td">Long Grove</td>
<td class="my-table-td">Logged In</td>
</tr>
<tr class="my-card-table-row-grey">
<td class="my-table-td">Teacher 3</td>
<td class="my-table-td">Lincolnshire</td>
<td class="my-table-td">Logged In</td>
</tr>
<tr class="my-card-table-row-white">
<td class="my-table-td">Teacher 4</td>
<td class="my-table-td">Buffalo Grove</td>
<td class="my-table-td">Logged In</td>
</tr>
<tr class="my-card-table-row-grey">
<td class="my-table-td">Teacher 5</td>
<td class="my-table-td">Kenilworth</td>
<td class="my-table-td">Not Logged In</td>
</tr>
<tr class="my-card-table-row-white">
<td class="my-table-td">Teacher 6</td>
<td class="my-table-td">Schaumburg</td>
<td class="my-table-td">Not Logged In</td>
</tr>
<tr class="my-card-table-row-grey">
<td class="my-table-td">Teacher 7</td>
<td class="my-table-td">Schaumburg</td>
<td class="my-table-td">Not Logged In</td>
</tr>
</table>

Related

Half Sticky Table with Html and Css

I have a table like in the picture:
What I am trying to achieve is I want the total part sticky on the table and Math, History and Biology etc. should be able to scroll right. S now the Math is next to the Total but I want History or Biology should be able to next to Total also.
Until now my code is like this:
.last-workouts .last-workout-table {
border-radius: 20px;
}
.last-workouts table {
border-collapse: collapse;
border-spacing: 0;
width: 100%;
border: 1px solid #ddd;
}
.last-workouts table .tests:not(:last-child) {
border-bottom: 1px solid #050a6c;
}
.last-workouts .test {
background-color: #00bad6;
text-align: center;
color: #FFFFFF;
padding: 1rem 0;
width: 20%;
}
.last-workouts .test .number-test,
.last-workouts .test .type-test {
font-weight: bold;
}
.last-workouts .result {
margin: 0;
padding: 0;
text-align: center;
width: 12%;
background-color: #F0F0F0;
}
.last-workouts .inner-table {
border: none;
}
.last-workouts .inner-table tr:not(:last-child) {
border-bottom: 1px solid #a9a9a9;
}
.last-workouts .total {
color: #00bad6;
font-weight: bold;
padding: .25rem;
}
.last-workouts .inner-table .box td {
padding: 0.5rem;
border: 1px solid #a9a9a9;
}
.last-workouts .inner-table .box .bold {
font-weight: bold;
}
.last-workouts .inner-table .box .bold.red {
color: red;
}
.last-workouts .inner-table .box div {
padding: .5rem;
}
.last-workouts .lessons {
margin: 0;
padding: 0;
text-align: center;
width: 12%;
}
.last-workouts .lessons:not(:last-child) {
border-right: 2px solid #000000;
}
<div class="last-workouts">
<div style="overflow-x:auto;" class="last-workout-table">
<table>
<tr class="tests">
<td class="test">
<div class="number-test">TYT-1</div>
<div class="type-test">Genel Deneme</div>
<div class="date">30.08.2021</div>
</td>
<td class="result">
<div class="total">
Toplam
</div>
<table class="inner-table">
<tr class="box">
<td>S</td>
<td>D</td>
<td>Y</td>
<td>B</td>
<td class="bold">Net</td>
<td class="bold">Puan</td>
</tr>
<tr class="box">
<td>115</td>
<td>80</td>
<td>6</td>
<td>16</td>
<td class="bold red">17.48</td>
<td class="bold red">490,54</td>
</tr>
</table>
</td>
<td class="lessons">
<div class="total">
Matematik
</div>
<table class="inner-table">
<tr class="box">
<td>S</td>
<td>D</td>
<td>Y</td>
<td>B</td>
<td class="bold">Net</td>
<td class="bold">Puan</td>
</tr>
<tr class="box">
<td>115</td>
<td>80</td>
<td>6</td>
<td>16</td>
<td class="bold red">17.48</td>
<td class="bold red">490,54</td>
</tr>
</table>
</td>
<td class="lessons">
<div class="total">
Turkce
</div>
<table class="inner-table">
<tr class="box">
<td>S</td>
<td>D</td>
<td>Y</td>
<td>B</td>
<td class="bold">Net</td>
<td class="bold">Puan</td>
</tr>
<tr class="box">
<td>115</td>
<td>80</td>
<td>6</td>
<td>16</td>
<td class="bold red">17.48</td>
<td class="bold red">490,54</td>
</tr>
</table>
</td>
<td class="lessons">
<div class="total">
Tarih
</div>
<table class="inner-table">
<tr class="box">
<td>S</td>
<td>D</td>
<td>Y</td>
<td>B</td>
<td class="bold">Net</td>
<td class="bold">Puan</td>
</tr>
<tr class="box">
<td>115</td>
<td>80</td>
<td>6</td>
<td>16</td>
<td class="bold red">17.48</td>
<td class="bold red">490,54</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
So how do you think I can achieve this?
Thanks
Nest .test and .result in an inner table and add position: sticky; left: 0; to the outer td.
.last-workouts .last-workout-table {
border-radius: 20px;
}
.last-workouts table {
border-collapse: collapse;
border-spacing: 0;
width: 100%;
border: 1px solid #ddd;
}
.last-workouts table .tests:not(:last-child) {
border-bottom: 1px solid #050a6c;
}
.last-workouts .test {
background-color: #00bad6;
text-align: center;
color: #FFFFFF;
padding: 1rem 0;
width: 20%;
}
.last-workouts .test .number-test,
.last-workouts .test .type-test {
font-weight: bold;
}
.last-workouts .result {
margin: 0;
padding: 0;
text-align: center;
width: 12%;
background-color: #F0F0F0;
}
.last-workouts .inner-table {
border: none;
}
.last-workouts .inner-table tr:not(:last-child) {
border-bottom: 1px solid #a9a9a9;
}
.last-workouts .total {
color: #00bad6;
font-weight: bold;
padding: .25rem;
}
.last-workouts .inner-table .box td {
padding: 0.5rem;
border: 1px solid #a9a9a9;
}
.last-workouts .inner-table .box .bold {
font-weight: bold;
}
.last-workouts .inner-table .box .bold.red {
color: red;
}
.last-workouts .inner-table .box div {
padding: .5rem;
}
.last-workouts .lessons {
margin: 0;
padding: 0;
text-align: center;
width: 12%;
}
.last-workouts .lessons:not(:last-child) {
border-right: 2px solid #000000;
}
<div class="last-workouts">
<div style="overflow-x:auto;" class="last-workout-table">
<table>
<tr class="tests">
<td style="position: sticky; left: 0;">
<table>
<td class="test">
<div class="number-test">TYT-1</div>
<div class="type-test">Genel Deneme</div>
<div class="date">30.08.2021</div>
</td>
<td class="result">
<div class="total">
Toplam
</div>
<table class="inner-table">
<tr class="box">
<td>S</td>
<td>D</td>
<td>Y</td>
<td>B</td>
<td class="bold">Net</td>
<td class="bold">Puan</td>
</tr>
<tr class="box">
<td>115</td>
<td>80</td>
<td>6</td>
<td>16</td>
<td class="bold red">17.48</td>
<td class="bold red">490,54</td>
</tr>
</table>
</td>
</table>
</td>
<td class="lessons">
<div class="total">
Matematik
</div>
<table class="inner-table">
<tr class="box">
<td>S</td>
<td>D</td>
<td>Y</td>
<td>B</td>
<td class="bold">Net</td>
<td class="bold">Puan</td>
</tr>
<tr class="box">
<td>115</td>
<td>80</td>
<td>6</td>
<td>16</td>
<td class="bold red">17.48</td>
<td class="bold red">490,54</td>
</tr>
</table>
</td>
<td class="lessons">
<div class="total">
Turkce
</div>
<table class="inner-table">
<tr class="box">
<td>S</td>
<td>D</td>
<td>Y</td>
<td>B</td>
<td class="bold">Net</td>
<td class="bold">Puan</td>
</tr>
<tr class="box">
<td>115</td>
<td>80</td>
<td>6</td>
<td>16</td>
<td class="bold red">17.48</td>
<td class="bold red">490,54</td>
</tr>
</table>
</td>
<td class="lessons">
<div class="total">
Tarih
</div>
<table class="inner-table">
<tr class="box">
<td>S</td>
<td>D</td>
<td>Y</td>
<td>B</td>
<td class="bold">Net</td>
<td class="bold">Puan</td>
</tr>
<tr class="box">
<td>115</td>
<td>80</td>
<td>6</td>
<td>16</td>
<td class="bold red">17.48</td>
<td class="bold red">490,54</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>

Table Row is not filling the full width of the table

I'm creating a HTML form and having an issue with getting the 2 column rows to fill the full width of the table. I have tried using colspace and setting a width to it but it's not working. I have also tried setting the width to 100% but it's also not working. CSS also doesn't seem to be making any changes to the
body {
width: 60%;
margin-left: auto;
margin-right: auto;
}
table {
width: 100%;
table-layout: fixed;
}
.heading {
text-align: center;
font-weight: bold;
padding: 5px;
text-decoration: underline;
}
img {
display: block;
margin-left: auto;
margin-right: auto;
padding: 25px;
}
.table-heading {
text-align: center;
padding: 20px;
font-weight: bold;
font-size: 14px;
background-color: #8080802e;
}
.demographics {
text-align: left;
}
table,
th,
td {
border: 2px solid black;
border-collapse: collapse;
padding: 6px;
}
<img src="https://via.placeholder.com/150" />
<table>
<tbody>
<tr>
<td class="table-heading" colspan="3">APPLICANT'S INFORMATION</td>
</tr>
<tr>
<td>Last Name:</td>
<td>First Name:</td>
<td>Middle Intial:</td>
</tr>
<tr>
<td colspan="2">Current Address:</td>
<td>City:</td>
</tr>
<tr>
<td>State:</td>
<td>Zip Code:</td>
<td>Phone #:</td>
</tr>
<tr>
<td colspan="2">Spouse's Name:</td>
<td>Phone #:</td>
</tr>
<tr>
<td class="table-heading" colspan="3">CHILDREN'S INFORMATION (NO STEP CHILDREN)</td>
</tr>
<tr>
<td>1)</td>
<td>5)</td>
</tr>
<tr>
<td>2)</td>
<td>6)</td>
</tr>
<tr>
<td>3)</td>
<td>7)</td>
</tr>
<tr>
<td>4)</td>
<td>8)</td>
</tr>
</tbody>
</table>
Because you have rows with 1, 2, and 3 columns, you need to use colspan with a number that is divisible by all three numbers, in this case, 6.
For one column per row, you would use colspan="6" because 6/6 = 1
For two columns per row, colspan="3" because 6/3 = 2
For three columns per row, colspan="2" because 6/2=2
Here is the HTML for a table with 1, 2, and 3 columns:
<table>
<tr>
<td colspan="6">One Column</td>
</tr>
<tr>
<td colspan="3">Two Column</td>
<td colspan="3">Two Column</td>
</tr>
<tr>
<td colspan="2">Three Column</td>
<td colspan="2">Three Column</td>
<td colspan="2">Three Column</td>
</tr>
</table>
Use Two Separate Table.
body {
width: 60%;
margin-left: auto;
margin-right: auto;
}
table {
width: 100%;
table-layout: fixed;
}
.heading {
text-align: center;
font-weight: bold;
padding: 5px;
text-decoration: underline;
}
img {
display: block;
margin-left: auto;
margin-right: auto;
padding: 25px;
}
.table-heading {
text-align: center;
padding: 20px;
font-weight: bold;
font-size: 14px;
background-color: #8080802e;
}
.demographics {
text-align: left;
}
table,
th,
td {
border: 2px solid black;
border-collapse: collapse;
padding: 6px;
}
.no-border-top{
border-top : 0
}
<img src="https://via.placeholder.com/150" />
<table>
<tbody>
<tr>
<td class="table-heading" colspan="3">APPLICANT'S INFORMATION</td>
</tr>
<tr>
<td>Last Name:</td>
<td>First Name:</td>
<td>Middle Intial:</td>
</tr>
<tr>
<td colspan="2">Current Address:</td>
<td>City:</td>
</tr>
<tr>
<td>State:</td>
<td>Zip Code:</td>
<td>Phone #:</td>
</tr>
<tr>
<td colspan="2">Spouse's Name:</td>
<td>Phone #:</td>
</tr>
</tbody>
</table>
<table class="no-border-top">
<tbody>
<tr>
<td class="table-heading no-border-top" colspan="2">CHILDREN'S INFORMATION (NO STEP CHILDREN)</td>
</tr>
<tr>
<td>1)</td>
<td>5)</td>
</tr>
<tr>
<td>2)</td>
<td>6)</td>
</tr>
<tr>
<td>3)</td>
<td>7)</td>
</tr>
<tr>
<td>4)</td>
<td>8)</td>
</tr>
</tbody>
</table>

tbody vertical scroll with sticky column

I have a table with a sticky column (see jsfiddle below). But I´m trying to have a vertical scroll just on the table body so the headers are always visible and the height of tbody should be fixed. How can I do this?
body {
font: 16px Calibri;
}
table {
border-collapse: separate;
border-top: 3px solid grey;
}
td,th {
margin: 0;
border: 3px solid grey;
border-top-width: 0px;
white-space: nowrap;
}
div {
width: 600px;
overflow-x: scroll;
margin-left: 5em;
overflow-y: visible;
padding-bottom: 1px;
}
.headcol {
position: absolute;
width: 5em;
left: 0;
top: auto;
border-right: 0px none black;
border-top-width: 3px;
/*only relevant for first row*/
margin-top: -3px;
/*compensate for top border*/
}
.long {
background: yellow;
letter-spacing: 1em;
}
<div>
<table>
<thead>
<tr>
<th class="headcol">sticky col</th>
<th>col2</th>
<th>col3</th>
</tr>
</thead>
<tbody>
<tr>
<td class="headcol">1</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">2</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">3</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">4</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">5</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">6</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">7</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">8</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
<tr>
<td class="headcol">9</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
</tr>
</tbody>
</table>
</div>
The end result should be similar to this:
http://demos.telerik.com/kendo-ui/grid/frozen-columns
You will need to set the position to fixed of the cell that you would like to remain fixed during vertical scroll.
.headcol {
position:fixed;
}

Table looks wrong in Chrome, after refreshing everything is ok

I've got problem with the table. On Firefox it looks great, but when I'm opening it on Chrome for first time table is in different position. Refresh repairs everything. What I did wrong?
CSS
#spec0{
background-color: #FFFFFF;
width: 566px;
border: 1px solid #ddd;
}
#spec1{
background-color: #F1F1F1;
width: 566px;
height: 20px;
}
#table {
border-collapse: collapse;
width: 566px;
border: 1px solid #ddd;
margin-top: 11px;
position: static;
}
#tr{
border: 1px solid #ddd;
height: 10px;
font-size: 11pt;
text-align: right;
}
#tr1{
border: 1px solid #ddd;
height: 10px;
font-size: 11pt;
}
#tr3{
height: 10px;
font-size: 11pt;
border: 1px solid #ddd;
text-align: left;
}
HTML
<table id="table">
<tr id="spec">
<th id="tr">Template</th>
<th id="tr3">Template</th>
</tr>
<tr id="spec1">
<td id="tr">Template</td>
<td id="tr1">Template</td>
</tr>
<tr id="spec">
<td id="tr">Template</td>
<td id="tr1">Template</td>
</tr>
<tr id="spec1">
<td id="tr">Template</td>
<td id="tr1">Template</td>
</tr>
<tr id="spec">
<td id="tr">Template</td>
<td id="tr1">Template</td>
</tr>
<tr id="spec1">
<td id="tr">Template</td>
<td id="tr1">Template</td>
</tr>
<tr id="spec">
<td id="tr">Template</td>
<td id="tr1">Template</td>
</tr>
<tr id="spec1">
<td id="tr">Template</td>
<td id="tr1">Template</td>
</tr>
<tr id="spec">
<td id="tr">Template</td>
<td id="tr1">Template</td>
</tr>
<tr id="spec1">
<td id="tr">Template</td>
<td id="tr1">Template</td>
</tr>
<tr id="spec">
<td id="tr">Template</td>
<td id="tr1">Template</td>
</tr>
<tr id="spec1">
<td id="tr"></td>
<td id="tr1">Template</td>
</tr>
</table>
image; first launch from Chrome
You are using mutiple equal ID's , ID's must be unique , so change to class, and you were trying to apply #spec0 when you had only id="spec"
.spec {
background-color: #FFFFFF;
width: 566px;
border: 1px solid #ddd;
}
.spec1 {
background-color: #F1F1F1;
width: 566px;
height: 20px;
}
#table {
border-collapse: collapse;
width: 566px;
border: 1px solid #ddd;
margin-top: 11px;
position: static;
}
.tr {
border: 1px solid #ddd;
height: 10px;
font-size: 11pt;
text-align: right;
}
.tr1 {
border: 1px solid #ddd;
height: 10px;
font-size: 11pt;
}
.tr3 {
height: 10px;
font-size: 11pt;
border: 1px solid #ddd;
text-align: left;
}
<table id="table">
<tr class="spec">
<th class="tr">Template</th>
<th class="tr3">Template</th>
</tr>
<tr class="spec1">
<td class="tr">Template</td>
<td class="tr1">Template</td>
</tr>
<tr class="spec">
<td class="tr">Template</td>
<td class="tr1">Template</td>
</tr>
<tr class="spec1">
<td class="tr">Template</td>
<td class="tr1">Template</td>
</tr>
<tr class="spec">
<td class="tr">Template</td>
<td class="tr1">Template</td>
</tr>
<tr class="spec1">
<td class="tr">Template</td>
<td class="tr1">Template</td>
</tr>
<tr class="spec">
<td class="tr">Template</td>
<td class="tr1">Template</td>
</tr>
<tr class="spec1">
<td class="tr">Template</td>
<td class="tr1">Template</td>
</tr>
<tr class="spec">
<td class="tr">Template</td>
<td class="tr1">Template</td>
</tr>
<tr class="spec1">
<td class="tr">Template</td>
<td class="tr1">Template</td>
</tr>
<tr class="spec">
<td class="tr">Template</td>
<td class="tr1">Template</td>
</tr>
<tr class="spec1">
<td class="tr"></td>
<td class="tr1">Template</td>
</tr>
</table>

Simple table cell text refuses to center

All I want, is for .TableH to be centered horizontally. I'm usually pretty decent at working small things like this out, but this is driving me nuts. I don't use tables as much as I should so if someone could help me, that would be great.
HTML:
<div id="Contactbody">
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d6118.82203107468!2d-74.17584896118852!3d39.932195088535714!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0x8c86de105986c5c3!2sEaglespeed+Oil+%26+Lube!5e0!3m2!1sen!2sus!4v1395432683622" frameborder="0" style="border:0"></iframe>
<table>
<tbody>
<tr>
<td class="TableH">Hours</td>
</tr>
<tr>
<td class="Day">Mon</td>
<td class="Hours">8 - 6</td>
</tr>
<tr>
<td class="Day">Tues</td>
<td class="Hours">8 - 6</td>
</tr>
<tr>
<td class="Day">Wed</td>
<td class="Hours">8 - 7</td>
</tr>
<tr>
<td class="Day">Thur</td>
<td class="Hours">8 - 6</td>
</tr>
<tr>
<td class="Day">Fri</td>
<td class="Hours">8 - 6</td>
</tr>
<tr>
<td class="Day">Sat</td>
<td class="Hours">7:30 - 3:30</td>
</tr>
<tr>
<td class="Day">Sun</td>
<td class="Hours">8:30 - 1</td>
</tr>
</tbody>
</table>
</div>
CSS:
#Contactbody {
position: absolute;
display: none;
margin: 8% 0 0 15%;
width: 70%;
height: auto;
border-left: 4px solid #ffe168;
}
#Contactbody iframe {
display: block;
float: left;
margin-left: 2.5%;
width: 40%;
height: auto;
}
#Contactbody table {
float: right;
margin-right: 5%;
width: 25%;
font-family: Aleygra Sans SC, Maven Pro, Verdana, Arial;
}
.TableH {
color: #0b0658;
vertical-align: middle;
font-weight: bold;
text-align: center;
}
Your cell is only spanning one column, you probably want:
<td class="TableH" colspan="2">Hours</td>