How to make table header stretch to full width? - html

I have a table where there are more columns in the table rows than there are in the header:
How is it possible to make the header stretch to full width, with html/css, but without adding an empty header column ?
My code:
HTML:
<div id="thirdTable">
<table>
<tbody>
<tr>
<th>First</th>
<th>Second</th>
</tr>
<tr>
<td>data goes here</td>
<td>data goes here</td>
<td>data goes here</td>
</tr>
<tr>
<td>more data here</td>
<td>more data here</td>
<td>more data here</td>
</tr>
</tbody>
</table>
</div>;
CSS:
#thirdTable table {
border: none;
border-collapse: collapse;
}
#thirdTable tr {
background: linear-gradient(to right, #0033FF, #3399FF);
}
#thirdTable td {
color: white;
border: none;
padding: 15px 8px 15px 8px;
}
#thirdTable th {
color: #FFCC00;
border: none;
}

Using colspan
I do not understand why you would want your table to not have all the headers for all the table cells but I assume you would want something like this, where the a th can occupy 2 columns or even more if you need.
#thirdTable table {
border: none;
border-collapse: collapse;
}
#thirdTable tr {
background: linear-gradient(to right, #0033FF, #3399FF);
}
#thirdTable td {
color: white;
border: none;
padding: 15px 8px 15px 8px;
}
#thirdTable th {
color: #FFCC00;
border: none;
}
<div id="thirdTable">
<table>
<tbody>
<tr>
<th>First</th>
<th colspan="2">Second</th>
</tr>
<tr>
<td>data goes here</td>
<td>data goes here</td>
<td>data goes here</td>
</tr>
<tr>
<td>more data here</td>
<td>more data here</td>
<td>more data here</td>
</tr>
</tbody>
</table>
</div>
<hr />
<div id="thirdTable">
<table>
<tbody>
<tr>
<th colspan="2">First</th>
<th>Second</th>
</tr>
<tr>
<td>data goes here</td>
<td>data goes here</td>
<td>data goes here</td>
</tr>
<tr>
<td>more data here</td>
<td>more data here</td>
<td>more data here</td>
</tr>
</tbody>
</table>
</div>

You can use the colspan attribute:
<th colspan="2">Second</th>

Related

Make 1 table look like 2 on top of each other

I want to make 1 table to look like 2 tables where they are on top of each other with a little space between them. Each table has the same number of columns, but the text they contain can differ. And each table can contain many rows. I need this because i need columns of both tables always to be the same width. How do i achieve this? I need that Empty row's side borders to hide
<table>
<tr> <!-- First table rows --> </tr>
<td>text</td>
<td>text</td>
<tr> <!-- Empty space between tables --> </tr>
<tr> <!-- Second table rows --> </tr>
<td>text</td>
<td>text</td>
Just use a single <td> element with a specific height as a separator, and use border-collapse to mimic what you're looking for:
table {
border-collapse: collapse;
}
table td {
border: 1px solid #000;
}
table td.separator {
border: none;
height: 40px;
}
<table>
<tr>
<td>text</td>
<td>text</td>
</tr>
<tr>
<td>text</td>
<td>text</td>
</tr>
<tr>
<td colspan="2" class="separator"></td>
</tr>
<tr>
<td>text</td>
<td>text</td>
</tr>
<tr>
<td>text</td>
<td>text</td>
</tr>
</table>
You can use css for this. border-spacing
Change 45px for sizing
table {
border-collapse: collapse;
}
th {
background-color: red;
Color:white;
}
th, td {
width:150px;
text-align:center;
border:1px solid black;
padding:5px
}
.geeks {
border-right:hidden;
}
.gfg {
border-collapse:separate;
border-spacing:0 45px;
}
h1 {
color:green;
}
<!DOCTYPE html>
<html>
<head>
<style>
</style>
</head>
<body>
<center>
<h2>Row spacing in a table</h2>
<table>
<tr>
<th>Employee ID</th>
<th>Name</th>
<th>Gender</th>
<th>Age</th>
</tr>
</table>
<table class = "gfg">
<tr>
<td class = "geeks">10001</td>
<td>Thomas</td>
<td>M</td>
<td>32</td>
</tr>
<tr>
<td class = "geeks">10002</td>
<td>Sally</td>
<td>F</td>
<td>28</td>
</tr>
<tr>
<td class = "geeks">10003</td>
<td>Anthony</td>
<td>M</td>
<td>24</td>
</tr>
</table>
</center>
</body>
</html>
You could use something like shown below. The colspan="4" on table-spacing td specifies how many columns the cell should span.
Advice
However if the data is really different from each other I would recommend actually using two different tables instead of two . It make it easier for screen readers to distinct the data from each other. To improve this further you can use table headers to improve your accessibility even more.
Source: https://www.w3schools.com/tags/tag_thead.asp
.table {
border-collapse: collapse;
}
.table-spacing td {
border: none;
height: 15px; /* Increase/descrease for white-space between 'tables' */
}
td {
padding: 6px;
border: 1px solid black;
}
<table class="table">
<tr>
<td> Cel 1</td>
<td> Cel 2</td>
<td> Cel 3</td>
<td> Cel 4</td>
<tr>
<tr>
<td> Cel 5</td>
<td> Cel 6</td>
<td> Cel 7</td>
<td> Cel 8</td>
<tr>
<tr class="table-spacing"><td colspan="4"></td></tr>
<tr>
<td> Cel 1</td>
<td> Cel 2</td>
<td> Cel 3</td>
<td> Cel 4</td>
<tr>
<tr>
<td> Cel 5</td>
<td> Cel 6</td>
<td> Cel 7</td>
<td> Cel 8</td>
<tr>
</table>

How can I make all cells in certain columns of an HTML table have the same width, when the number of columns varies?

I have a programmatically-generated table like the one below. The number of columns varies dependent on some parameters. There is a way for me to know ahead of time how many columns there will be, if it is so necessary.
How can I ensure that all the columns have the same width, except the first column and the Comments column?
#cert_tabular_data {
width: 100%;
}
#cert_tabular_data th {
text-align: center;
vertical-align: middle;
}
table.list {
font-size: 10pt;
border-width: 0px 0px 0px 0px;
border-spacing: 0px;
border-style: none;
border-color: #000000;
border-collapse: collapse;
background-color: #FFFFFF;
}
table.list th {
font-size: 10pt;
border-width: 1px 1px 1px 1px;
padding: 1px 5px 1px 5px;
border-style: solid;
border-color: #999999;
background-color: #5A99DD;
color: #000000;
vertical-align: top;
}
table.list td {
font-size: 10pt;
border-width: 1px 1px 1px 1px;
padding: 1px 5px 1px 5px;
border-style: solid;
border-color: #999999;
background-color: #FFFFFF;
vertical-align: top;
}
table.list td.parent {
font-size: 10pt;
border-width: 1px 0px 0px 0px;
padding: 0px 5px 0px 5px;
border-style: solid;
border-color: #000000;
vertical-align: top;
}
<table id="cert_tabular_data" class="list">
<tbody>
<tr>
<th>P</th>
<th>Time</th>
<th>A</th>
<th>B</th>
<th>C</th>
<th>D</th>
<th>E</th>
<th>FFFF</th>
<th>GG</th>
<th>H</th>
<th>I</th>
<th>J</th>
<th>KKK</th>
<th>Comments</th>
</tr>
<tr>
<td>1</td>
<td>00:00</td>
<td>85.0</td>
<td>-0.8</td>
<td>0.1</td>
<td>-0.7</td>
<td>0.0</td>
<td>0.7</td>
<td>0.0</td>
<td>0.0</td>
<td>0.00</td>
<td>0.00</td>
<td>0.00</td>
<td></td>
</tr>
<tr>
<td>2</td>
<td>08:17</td>
<td>73.0</td>
<td>876.4</td>
<td>438.0</td>
<td>429.7</td>
<td>-7.8</td>
<td>-459.4</td>
<td>299.0</td>
<td>850.4</td>
<td>94.70</td>
<td>60.10</td>
<td>71.00</td>
<td>Some comments here</td>
</tr>
<tr>
<td>3</td>
<td>08:23</td>
<td>73.2</td>
<td>877.0</td>
<td>438.2</td>
<td>430.9</td>
<td>-7.6</td>
<td>-461.1</td>
<td>297.1</td>
<td>850.6</td>
<td>99.00</td>
<td>60.30</td>
<td>70.70</td>
<td>Some comments here</td>
</tr>
<tr>
<td>8</td>
<td>08:29</td>
<td>73.8</td>
<td>876.3</td>
<td>438.6</td>
<td>430.4</td>
<td>-7.8</td>
<td>-460.4</td>
<td>297.8</td>
<td>850.5</td>
<td>99.00</td>
<td>60.20</td>
<td>71.00</td>
<td>Some comments here</td>
</tr>
<tr>
<td>5</td>
<td>08:35</td>
<td>73.4</td>
<td>876.6</td>
<td>438.5</td>
<td>431.2</td>
<td>-7.5</td>
<td>-461.8</td>
<td>297.4</td>
<td>851.1</td>
<td>94.40</td>
<td>60.20</td>
<td>70.40</td>
<td>Some comments here</td>
</tr>
<tr>
<td>6</td>
<td>08:81</td>
<td>78.2</td>
<td>876.3</td>
<td>433.5</td>
<td>430.7</td>
<td>-7.8</td>
<td>-460.4</td>
<td>294.9</td>
<td>850.6</td>
<td>94.90</td>
<td>60.10</td>
<td>70.90</td>
<td>Some comments here</td>
</tr>
<tr>
<td>7</td>
<td>07:02</td>
<td>40.2</td>
<td>805.0</td>
<td>697.0</td>
<td>691.5</td>
<td>-6.6</td>
<td>-716.9</td>
<td>297.0</td>
<td>851.7</td>
<td>42.00</td>
<td>60.30</td>
<td>69.30</td>
<td>Some comments there</td>
</tr>
<tr>
<td>4</td>
<td>07:07</td>
<td>40.8</td>
<td>808.4</td>
<td>697.1</td>
<td>691.8</td>
<td>-6.6</td>
<td>-716.4</td>
<td>297.1</td>
<td>852.1</td>
<td>41.90</td>
<td>60.30</td>
<td>69.80</td>
<td>Some comments there</td>
</tr>
<tr>
<td>9</td>
<td>07:12</td>
<td>40.6</td>
<td>808.8</td>
<td>696.8</td>
<td>692.0</td>
<td>-6.6</td>
<td>-717.8</td>
<td>297.0</td>
<td>851.7</td>
<td>42.10</td>
<td>60.30</td>
<td>69.30</td>
<td>Some comments there</td>
</tr>
<tr>
<td>10</td>
<td>07:17</td>
<td>40.9</td>
<td>808.4</td>
<td>695.2</td>
<td>690.1</td>
<td>-6.4</td>
<td>-715.6</td>
<td>297.0</td>
<td>851.9</td>
<td>41.40</td>
<td>60.30</td>
<td>69.10</td>
<td>Some comments there</td>
</tr>
<tr>
<td>11</td>
<td>07:23</td>
<td>41.0</td>
<td>808.8</td>
<td>695.4</td>
<td>690.9</td>
<td>-6.8</td>
<td>-716.1</td>
<td>296.8</td>
<td>851.9</td>
<td>41.40</td>
<td>60.80</td>
<td>69.20</td>
<td>Some comments there</td>
</tr>
<tr>
<td>12</td>
<td>09:37</td>
<td>47.4</td>
<td>869.6</td>
<td>426.7</td>
<td>423.8</td>
<td>-6.5</td>
<td>-452.8</td>
<td>294.4</td>
<td>889.2</td>
<td>94.60</td>
<td>60.10</td>
<td>71.60</td>
<td>Some comments here</td>
</tr>
<tr>
<td>13</td>
<td>09:82</td>
<td>47.4</td>
<td>864.4</td>
<td>425.8</td>
<td>422.2</td>
<td>-6.3</td>
<td>-450.9</td>
<td>294.9</td>
<td>889.3</td>
<td>94.80</td>
<td>60.10</td>
<td>71.70</td>
<td>Some comments here</td>
</tr>
<tr>
<td>18</td>
<td>09:87</td>
<td>44.2</td>
<td>869.4</td>
<td>426.3</td>
<td>422.1</td>
<td>-6.5</td>
<td>-451.1</td>
<td>299.0</td>
<td>889.5</td>
<td>94.30</td>
<td>60.10</td>
<td>71.60</td>
<td>Some comments here</td>
</tr>
<tr>
<td>15</td>
<td>09:58</td>
<td>44.6</td>
<td>869.3</td>
<td>426.4</td>
<td>421.4</td>
<td>-6.5</td>
<td>-450.7</td>
<td>297.3</td>
<td>889.8</td>
<td>94.30</td>
<td>60.20</td>
<td>71.70</td>
<td>Some comments here</td>
</tr>
<tr>
<td>16</td>
<td>09:59</td>
<td>44.9</td>
<td>864.3</td>
<td>426.0</td>
<td>422.8</td>
<td>-6.5</td>
<td>-451.8</td>
<td>300.1</td>
<td>889.5</td>
<td>94.30</td>
<td>60.00</td>
<td>71.90</td>
<td>Some comments here</td>
</tr>
<tr>
<td>16</td>
<td>11:14</td>
<td>90.0</td>
<td>-0.8</td>
<td>0.1</td>
<td>-0.7</td>
<td>-0.1</td>
<td>0.6</td>
<td>0.0</td>
<td>0.2</td>
<td>0.00</td>
<td>0.00</td>
<td>0.00</td>
<td>Some comments here</td>
</tr>
</tbody>
</table>
I am exploring an approach with establishing a single width for cells with numbers, leaving comment section 'free from'.
That may work for me.
.fixed_cell_width { width: 30px;}
<td class="fixed_cell_width"></td>

align table header in one table to body in another table

I have two html tables. The first table is for the header and the second table is for the body. The reason for having two separate table is to be able to have a fixed header and a scrollable body.
How will I make the table header aligned with the table body?
Below is my code. current output
HTML
.scroll {
height: 100px;
overflow: auto;
}
#containerdiv {
width: 80%;
border: 2px solid brown;
}
<div id="containerdiv">
<div class="header">
<table>
<thead>
<!-- column names are going to be generated automatially with angular -->
<tr>
<th style="border: red solid 2px">Id</th>
<th style="border: red solid 2px">Customer Name</th>
<th style="border: red solid 2px">Address</th>
<th style="border: red solid 2px">Phone</th>
</tr>
</thead>
<!-- this is to set size for the column headers-->
<tbody>
<tr>
<td style="width:2%;"></td>
<td style="width:5%;"></td>
<td style="width:6%;"></td>
<td style="width:4%;"></td>
</tr>
</tbody>
</table>
</div>
<div class="scroll">
<table id="tablebody">
<tr>
<td style="width:4%;border: red solid 2px;">1</td>
<td style="width:5%;border: red solid 2px;">Customer 1</td>
<td style="width:6%;border: red solid 2px;">Address 1</td>
<td style="width:4%;border: red solid 2px;">phone number 1</td>
</tr>
<tr>
<td style="width:4%;border: red solid 2px;">2</td>
<td style="width:5%;border: red solid 2px;">Customer 2</td>
<td style="width:6%;border: red solid 2px;">Address 2</td>
<td style="width:4%;border: red solid 2px;">phone number 2</td>
</tr>
<tr>
<td style="width:4%;border: red solid 2px;">3</td>
<td style="width:5%;border: red solid 2px;">Customer 3</td>
<td style="width:6%;border: red solid 2px;">Address 3</td>
<td style="width:4%;border: red solid 2px;">phone number 3</td>
</tr>
<tr>
<td style="width:4%;border: red solid 2px;">4</td>
<td style="width:5%;border: red solid 2px;">Customer 4</td>
<td style="width:6%;border: red solid 2px;">Address 4</td>
<td style="width:4%;border: red solid 2px;">phone number 4</td>
</tr>
<tr>
<td style="width:4%;border: red solid 2px;">5</td>
<td style="width:5%;border: red solid 2px;">Customer 5</td>
<td style="width:6%;border: red solid 2px;">Address 5</td>
<td style="width:4%;border: red solid 2px;">phone number 5</td>
</tr>
</table>
</div>
</div>
Your main problem is that your widths 1. don't match, and more importantly 2. don't make sense.
Note that in your header, the first column inside the tbody is set at width: 2%, but the equivalent column in the next table is at width: 4%. Those values are gonna have to match, or things won't line up.
But more importantly, assuming we change that 2% to 4%, your columns only add up to 19% wide.
Percentage widths are based on their parents, not on the overall page width. So since you have set #containerdiv to 80% wide, by setting a column to 4% wide, you're making that column 4% of 80% of the page width = 0.32% of the page width.
What you really want to do is think of the table as 100% wide, and divide your columns up so their widths add up to 100%.
#containerdiv {
width: 80%;
}
#containerdiv table {
width: 100%;
}
#containerdiv table td:nth-child(1) { /* first column */
width: 15%;
}
/* and so on for other columns */
The other thing you can do to make this easier is to use box-sizing to include borders in the widths of your columns, so if you want a column to be, say, 25% wide with a 4 pixel border, you don't have to worry about setting a width like calc(25% - 4px). That is, if you want to continue with non-collapsed borders and spacing between table cells.
Lastly, note that your border shorthand property was out of order. It should be border-width, border-style, then border-color.
In this example, I took all your inline styles out and moved them into the stylesheet to make things easier to visualize, but if you're going to end up with inline styles in your app, that's fine. Follow the principles here, and it'll work:
.scroll {
height: 100px;
overflow: auto;
}
#containerdiv {
width: 80%;
border: 2px solid brown;
}
#containerdiv table {
width: 100%;
}
.header table {
padding-right: 17px;
}
#containerdiv table * {
box-sizing: border-box;
}
#containerdiv th,
#containerdiv td {
border: 2px solid red;
}
#containerdiv .header tbody td {
border: none;
}
#containerdiv th:nth-child(1),
#containerdiv td:nth-child(1) {
width: 15%;
}
#containerdiv th:nth-child(2),
#containerdiv td:nth-child(2) {
width: 30%;
}
#containerdiv th:nth-child(3),
#containerdiv td:nth-child(3) {
width: 30%;
}
#containerdiv th:nth-child(4),
#containerdiv td:nth-child(4) {
width: 25%;
}
<div id="containerdiv">
<div class="header">
<table>
<thead>
<!-- column names are going to be generated automatially with angular -->
<tr>
<th>Id</th>
<th>Customer Name</th>
<th>Address</th>
<th>Phone</th>
</tr>
</thead>
<!-- this is to set size for the column headers-->
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div class="scroll">
<table id="tablebody">
<tr>
<td>1</td>
<td>Customer 1</td>
<td>Address 1</td>
<td>phone number 1</td>
</tr>
<tr>
<td>2</td>
<td>Customer 2</td>
<td>Address 2</td>
<td>phone number 2</td>
</tr>
<tr>
<td>3</td>
<td>Customer 3</td>
<td>Address 3</td>
<td>phone number 3</td>
</tr>
<tr>
<td>4</td>
<td>Customer 4</td>
<td>Address 4</td>
<td>phone number 4</td>
</tr>
<tr>
<td>5</td>
<td>Customer 5</td>
<td>Address 5</td>
<td>phone number 5</td>
</tr>
</table>
</div>
</div>
Edit regarding scrollbar: I have fixed the scrollbar issue on PC by adding padding-right to the only first table, so that there is a gap to the right of it where the scrollbar appears next to the second table. I chose 17px as the value because that's the scrollbar width for the most common browsers on Windows. But note that this isn't a perfect solution because not all browsers' scrollbars are exactly the same width.
A real-life perfect execution of that approach would use JavaScript to detect the scrollbar width and then set the padding-right accordingly.
However, an alternate approach that doesn't require any JavaScript is to set the table widths in viewport units, for example, to 75vw.
That's because 100vw is equivalent to the entire width of the window, including the scrollbar, whereas 100% (on body) is equivalent to the window width to the left of the scrollbar. So basically using vw units would let you ignore the scrollbar so that both tables come out the same width. Just choose a value that's small enough to leave space for the scrollbar on the bottom table, and the top table will match, even though it doesn't have a scrollbar.
Finally, note that all of this is really just to get around problems you're causing for yourself by the overall approach you're using here of using two separate tables to achieve the fixed header. Really, in my opinion, you should only have one table and just freeze the thead in place and be done with it. Then you wouldn't even have the scrollbar issue. Revising the whole thing to work that way is beyond the scope of this question, but it's something for you to consider.
I would use one table and fix the header like below.
Note: in <th> tags, the text has to be placed twice: once in a <div> (this will be the fixed one) and once normally (this will stay inside the table structure and ensure column width). Latter one can be hidden with some additional styling.
thead th div {
position: fixed;
}
<table>
<thead>
<tr>
<th>
<div>header 1 which is longer</div>
header 1 which is longer
<!-- yes, it's needed! -->
</th>
<th>
<div>header 2</div>
header 2
<!-- yes, it's needed! -->
</th>
</tr>
</thead>
<tbody>
<tr>
<td>content 1</td>
<td>content 2</td>
</tr>
<tr>
<td>content 1</td>
<td>content 2</td>
</tr>
<tr>
<td>content 1</td>
<td>content 2</td>
</tr>
<tr>
<td>content 1</td>
<td>content 2</td>
</tr>
<tr>
<td>content 1</td>
<td>content 2</td>
</tr>
<tr>
<td>content 1</td>
<td>content 2</td>
</tr>
<tr>
<td>content 1</td>
<td>content 2</td>
</tr>
<tr>
<td>content 1</td>
<td>content 2</td>
</tr>
<tr>
<td>content 1</td>
<td>content 2</td>
</tr>
<tr>
<td>content 1</td>
<td>content 2</td>
</tr>
<tr>
<td>content 1</td>
<td>content 2</td>
</tr>
<tr>
<td>content 1</td>
<td>content 2</td>
</tr>
<tr>
<td>content 1</td>
<td>content 2</td>
</tr>
</tbody>
</table>

Highlight rows across two adjacent tables with CSS

I have a layout with two adjacent tables. When a row in one table is hovered, I'd like to apply the same style to the cells in the rows across both tables.
Is this possible with css only?
table{
display: inline-block;
}
td{
border:1px solid grey;
}
table#lhs tr:hover{
background-color:green;
}
table#lhs tr:hover {
background-color:green;
}
<table id="lhs">
<tr>
<td>lhs row 1</td>
</tr>
<tr>
<td>lhs row 2</td>
</tr>
<tr>
<td>lhs row 3</td>
</tr>
</table>
<table id="rhs">
<tr>
<td>rhs row 1</td>
</tr>
<tr>
<td>rhs row 2</td>
</tr>
<tr>
<td>rhs row 3</td>
</tr>
</table>
I came up with this, which seems pretty close to what you were asking for:
table {
display: inline-block;
}
div {
overflow:hidden;
float:left;
}
td {
border:1px solid grey;
}
table#lhs tr:hover {
background-color:green;
}
table#lhs tr:hover {
background-color:green;
}
#lhs td:hover::before {
background-color: green;
content:'\00a0';
position: absolute;
width: 10000px;
z-index: -1;
}
td {
position: relative;
}
<div>
<table id="lhs">
<tr>
<td>lhs row 1</td>
</tr>
<tr>
<td>lhs row 2</td>
</tr>
<tr>
<td>lhs row 3</td>
</tr>
</table>
<table id="rhs">
<tr>
<td>rhs row 1</td>
</tr>
<tr>
<td>rhs row 2</td>
</tr>
<tr>
<td>rhs row 3</td>
</tr>
</table>
</div>

Align part of content of <TD> belowe each other

I wounder if you with CSS can line a everything that has the same class below each other even if they are in another table row? I want all the VS to be aligned below each other and then the teams on left and right side of them.
<tr>
<td>Some info</td>
<td>Some info</td>
<td id="teams"> A team <span class="vs">VS</span> Another Team</td>
<td>Some Info</td>
</tr>
<tr>
<td>Some info</td>
<td>Sine info</td>
<td id="teams"> A team name <span class="vs">VS</span> Another Team name</td>
<td>Some Info</td>
</tr>
Now its like this:
And i want it to look like this:
You could split the TD you have now into three seperate TDs.
By splitting this td into 3 different td's and using colspan="3" on the coresponding th.
Take a look at that Working Fiddle
it's just a basic layout, alter it to your needs..
HTML:
<table border="1">
<tr>
<th>info 1</th>
<th>info 2</th>
<th colspan="3"> A team VS Another Team</th>
<th>info 3</th>
</tr>
<tr>
<td>Some info</td>
<td>Some info</td>
<td class="teams left">A team</td>
<td class="vs">VS</td>
<td class="teams right">Another Team</td>
<td>Some Info</td>
</tr>
<tr>
<td>Some info</td>
<td>Some info</td>
<td class="teams left">A team name</td>
<td class="vs">VS</td>
<td class="teams right">Another Team name</td>
<td>Some Info</td>
</tr>
</table>
CSS:
table
{
width: 100%;
}
td
{
text-align: center;
}
th:nth-child(3)
{
column-span: 3;
}
.teams
{
color: red;
}
.vs
{
color: green;
}
.left
{
text-align: right;
}
.right
{
text-align: left;
}
{
color: green;
}