How can I make border 1px for table td. I have a table and I want to make the border 1px. Thank you!
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
</table>
You can use like this
table { border-collapse: collapse;}
for table.
And give
td {
border: 1px solid red;
}
You can use border-collapse for table with css.
Try This:
td {
border: 1px solid #000;
}
td {
border: 1px solid #000;
}
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
</table>
Or
table {
border-collapse: collapse;
}
td {
border: 1px solid #000;
}
table {
border-collapse: collapse;
}
td {
border: 1px solid #000;
}
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
</table>
You can define a CSS style for td.
This will affect all tables in HTML page.
<style>
td {
border:1px solid black
}
</style>
<table >
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
</table>
Try like this :
table {
border-collapse: collapse;
}
table, td, th {
border: 1px solid black;
}
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
</table>
Related
I tried to create html tables with header.
I added 2 rows but I couldn't figure out how to align to header.
My desired result is like this.
below is my previous work.
What is wrong point? how can I fix it? if someone has opinion please let me know.
Thanks
td {
padding:5px;
border:solid black 1px;}
table{
border-collapse:collapse;
border:solid black 1px;}
<table>
<tr>
<th>header</th>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
</table>
I hope this will help you:
td {
padding:5px;
border:solid black 1px;}
table{
border-collapse:collapse;
border:solid black 1px;}
<table>
<tr>
<th rowspan="2">header</th>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
</table>
You have to use rowspan="2" since you want to merge 2 rows.
td {
padding: 5px;
border: solid black 1px;
}
table {
border-collapse: collapse;
border: solid black 1px;
}
<table>
<tr>
<th rowspan="2">header</th>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>11</td>
<td>12</td>
<td>13</td>
<td>14</td>
<td>15</td>
</tr>
</table>
Please find attached the solution:
<table>
<tr>
<td rowspan="2"> Header</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
</table>
I would like to get stripped html tables.
My desired result is like below.
Are there any method to realize it ?
Thanks
td {
padding:5px;
border: solid black 1px;}
table {
border-collapse:collapse;}
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
</table>
Use a combination of border-spacing and border-collapse. Refer here
table {
border-collapse: collapse;
}
th {
background-color: green;
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 15px;
}
h1 {
color: green;
}
<table class="gfg">
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
</table>
Here you are:
td {
padding:5px;
//border: solid black 1px;}
tr:nth-child(odd) td {
border: solid black 1px;
}
table {
border-collapse:collapse;
}
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
</table>
I have html tables and I would like to add summary columns next to it.
I could create simple table, but I couldn't figure out how to set separate tables next to it.
My desired result is described below. If someone has idea, please let me know.
td {
border: solid 1px black;
padding:5px;
}
table {
border-collapse: collapse;
}
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
</table>
Here you go with a solution
td {
border: solid 1px black;
padding:5px;
}
table {
border-collapse: collapse;
}
.noborder {
border: none;
padding: 5px 8px;
}
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td class="noborder"></td>
<td>2</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
<td class="noborder"></td>
<td>2</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
<td class="noborder"></td>
<td>2</td>
</tr>
</table>
Rather than creating another table I will suggest to use the no-border cell.
Hope this will help you
According to your requirement, you actually do not need another table, but in future if you want to use table side by side then you can use below solution.
td {
border: solid 1px black;
padding:5px;
}
table {
border-collapse: collapse;
float:left;
}
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
</table>
<table style="margin-left:20px">
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
</table>
I got what I want as per the screenshot. However, the borders got attached to one another and got thicker. How do I maintain the border size?
This is actually what I'm planning to make it look like:
DEMO: https://jsfiddle.net/xnqh9d70/
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>Day</td>
<td>Sun.</td>
<td>Mon.</td>
<td>Tues.</td>
<td>Wed.</td>
<td>Thu.</td>
<td>Fri.</td>
<td>Sat.</td>
<td></td>
</tr>
<tr>
<td>Fare(s)</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td></td>
</tr>
<tr>
<td>Date(s)</td>
<td>9</td>
<td>8</td>
<td>7</td>
<td>6</td>
<td>5</td>
<td>4</td>
<td>3</td>
<td>2</td>
</tr>
</tbody>
</table>
CSS:
table {
border-collapse: separate;
empty-cells: hide;
border: 0;
border-color: #000000;
}
This is probably not the nicest solution, but what you can do is eliminate one of the two borders completely, only having borders on elements where it is needed then.
table {
border-collapse: separate;
empty-cells: hide;
border: 0;
border-color: #000000;
border-left: 1px solid black
}
tr {
border-bottom: none;
}
td {
border-left: none;
}
tr:last-of-type {
border-bottom: 1px solid black;
}
td:first-of-type {
border-right: 1px solid black;
}
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>Day</td>
<td>Sun.</td>
<td>Mon.</td>
<td>Tues.</td>
<td>Wed.</td>
<td>Thu.</td>
<td>Fri.</td>
<td>Sat.</td>
<td></td>
</tr>
<tr>
<td>Fare(s)</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td></td>
</tr>
<tr>
<td>Date(s)</td>
<td>9</td>
<td>8</td>
<td>7</td>
<td>6</td>
<td>5</td>
<td>4</td>
<td>3</td>
<td>2</td>
</tr>
</tbody>
</table>
The general way for creating borders between cells is by styling the td elements, and setting border-collapse: collapse; on the table.
I also added a class for your blank cells to remove the border on them.
table {
empty-cells: hide;
border-collapse: collapse;
border-color: #000000;
}
td {
border: 1px solid black;
}
.empty-cell {
border: none;
}
<table>
<tbody>
<tr>
<td>Day</td>
<td>Sun.</td>
<td>Mon.</td>
<td>Tues.</td>
<td>Wed.</td>
<td>Thu.</td>
<td>Fri.</td>
<td>Sat.</td>
<td class="empty-cell"></td>
</tr>
<tr>
<td>Fare(s)</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td class="empty-cell"></td>
</tr>
<tr>
<td>Date(s)</td>
<td>9</td>
<td>8</td>
<td>7</td>
<td>6</td>
<td>5</td>
<td>4</td>
<td>3</td>
<td>2</td>
</tr>
</tbody>
</table>
empty-cells: hide; is use to hide border
The empty-cells property sets whether or not to display borders on
empty cells in a table. Reference Here
you can apply css to td:empty for hide empty td
and for border-collapse: separate; case you need to add manually border-right to last td
table {
border-collapse: collapse;
border-color: #000000;
empty-cells: hide;
}
td {
border: 1px solid black;
}
td:empty {
border: 0px;
}
<table>
<tbody>
<tr>
<td>Day</td>
<td>Sun.</td>
<td>Mon.</td>
<td>Tues.</td>
<td>Wed.</td>
<td>Thu.</td>
<td>Fri.</td>
<td>Sat.</td>
<td></td>
</tr>
<tr>
<td>Fare(s)</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td></td>
</tr>
<tr>
<td>Date(s)</td>
<td>9</td>
<td>8</td>
<td>7</td>
<td>6</td>
<td>5</td>
<td>4</td>
<td>3</td>
<td>2</td>
</tr>
</tbody>
</table>
This table:
<table border="1">
<tbody><tr>
<td></td>
<td>Grokkability</td>
<td>PIA Factor*</td>
<td>FancyPantsiness</td>
</tr>
<tr>
<td>XML</td>
<td>10</td>
<td>8</td>
<td>2</td>
</tr>
<tr>
<td>Code</td>
<td>10</td>
<td>5</td>
<td>4</td>
</tr>
<tr>
<td>Auto-Wiring</td>
<td>2</td>
<td>2</td>
<td>10</td>
</tr>
</tbody></table>
...looks as I want it to on jsfiddle (http://jsfiddle.net/clayshannon/9AX8H/), but on Code Project it has lost its cell formatting (http://www.codeproject.com/Tips/711127/Swapping-Out-Concrete-Implementations-of-Interface)
What must I do to force the cell boundaries to be visible?
You probably want to use css..
<table class="border">
<tbody><tr>
<th></th>
<th>Grokkability</th>
<th>PIA Factor*</th>
<th>FancyPantsiness</th>
</tr>
<tr>
<th>XML</th>
<td>10</td>
<td>8</td>
<td>2</td>
</tr>
<tr>
<th>Code</th>
<td>10</td>
<td>5</td>
<td>4</td>
</tr>
<tr>
<th>Auto-Wiring</th>
<td>2</td>
<td>2</td>
<td>10</td>
</tr>
</tbody></table>
Your css
.border {
border: solid 1pt;
border-collapse:collapse;
}
.border th{
border: 1px solid #000000;
padding: 4px;
background-color: #34B767;
}
.border td{
border: 1px solid;
padding: 4px;
}