There is a 1px margin/padding around my td elements:
td {
margin: 0;
padding: 0;
background-color: blue;
}
How do I remove this?
You have something that looks like this:
td {
width: 10px;
height: 10px;
background: blue;
}
<table>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</table>
Add this CSS to your page:
table, td {
border-collapse: collapse;
}
Like so:
table, td {
border-collapse: collapse;
}
td {
width: 10px;
height: 10px;
background: blue;
}
<table>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</table>
Please try this.
<table border="1" style="border-spacing: 0;border-collapse: collapse;">
<tr>
<td>test</td>
<td>test</td>
<tr>
<tr>
<td>test</td>
<td>test</td>
<tr>
</table>
Hope this helps.
Thanks
Related
I am struggling to make a html table that copies the layout of the table above.
I am just wondering what techniques to use and to recreate that table
I have tried nested tables and have looked into using div instead to create this but am still having issues, mainly with the way that the lines are presented in this and are not in an obvious layout
Here is a cool tool:
https://tabletag.net/
Here you need to nest a table in the second row
table,
td,
th {
border: 1px solid #595959;
border-collapse: collapse;
}
td,
th {
padding: 3px;
width: 30px;
height: 25px;
}
th {
background: #f0e6cc;
}
.even {
background: #fbf8f0;
}
.odd {
background: #fefcf9;
}
<table>
<tbody>
<tr>
<td colspan="3"></td>
<td colspan="5"></td>
<td colspan="3" rowspan="2"></td>
</tr>
<tr>
<td colspan="3"></td>
<td colspan="5"></td>
</tr>
<tr>
<td colspan="6"></td>
<td colspan="5"></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
If make table with 9 tds, add borders, how to remove border around parent?
I need to remove this border:
table tr {
border: none !important;
}
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="td"></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
.border-none {
border-collapse: collapse;
border: none;
}
.border-none td {
border: 1px solid black;
}
.border-none tr:first-child td {
border-top: none;
}
.border-none tr:last-child td {
border-bottom: none;
}
.border-none tr td:first-child {
border-left: none;
}
.border-none tr td:last-child {
border-right: none;
}
<table class="border-none" border="1" cellspacing="0" cellpadding="10">
<tbody>
<tr>
<td class="td"></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
You Can Use Border-collapse Border Collapse
table,
tr,
th {
border-collapse: collapse;
}
td {
width: 200px;
height: 200px;
border: 2px solid red;
}
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="td"></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
I have tried this:
<table class="travaux">
<tr>
<th>Nature de l’opération</th>
<th>Unité</th>
<th>Quantité</th>
<th>P.U (dh)</th>
<th>Coût (dh)</th>
<th>N.J.T</th>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="3">Coût total : </td>
</tr>
<tr>
<td colspan="3">TVA (20%) : </td>
</tr>
<tr>
<td colspan="3">T.T.C : </td>
</tr>
</table>
.techniques{
width: 70%;
}
.techniques,.techniques th, .techniques td{
border: 1px solid;
border-collapse: collapse;
}
.techniques td{
border-top: hidden;
text-align: center;
padding: 6px;
}
to get this:
but I only get it like this:
please Could anyone tell me how I can get total section on the right instead of left?
<tr>
<td colspan="3" style="border-left: none;border-bottom: none;"></td>
<td colspan="3">Coût total : </td>
</tr>
that should do it. You can't just use 3 cols, when you got a 6 col layout
I want to have a table like you see in the picture.
But I am really unsuccessful in this.
here is my code:
table,
td,
th {
border: 1px solid black;
}
table {
width: 100%;
border-collapse: collapse;
}
<table>
<tr>
<td>SOL</td>
<td>K</td>
<td>Y</td>
<td>M</td>
</tr>
<tr>
<td>
<td>b</td>
<td>a1</td>
</td>
<td>b</td>
<td>b</td>
</tr>
</table>
Could you please help me on this?
Here's the solution
table {
width: 100%;
border-collapse: collapse;
}
table,
th,
td {
border: 1px solid lightgray;
font-family: sans-serif;
padding: 7px 15px;
}
<table>
<tbody>
<tr>
<th colspan="2">SOL</th>
<th>K</th>
<th>Y</th>
<th>M</th>
</tr>
<tr>
<td></td>
<td>a1</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td rowspan="2">1</td>
<td>a2</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>b1</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td>b2</td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
I have this table, I try to wrap the green span elements (a,b,c,d,e,f) so that all columns have the same width and put the extra spans in extra lines of the same cell increasing the height. As it is now, the first column takes its width from the spans and all are in one line. I tried changing the display and word-wrap options but did nothing.
body {
background-color: #444;
}
table {
border-collapse: collapse;
}
table,
th,
td {
border: 1px solid black;
font-size: 30px;
height: 40px;
text-align: center;
}
td {
width: 100px;
}
.goods td:nth-child(1){
color:green;
}
.goods span{
border: 1px solid green;
border-radius:15px;
padding-right: 5px;
width:13px;
cursor:pointer;
}
<table id="main">
<tr>
<td>K</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>*</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>*</td>
</tr>
<tr class="goods">
<td><span id="good1">a</span><span id="good2">b</span><span id="good3">c</span><span id="good4">d</span><span id="good5">e</span><span id="good6">f</span></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td><span id="ship">+</span></td>
</tr>
</table>
span is inline element by default so you have to change display property to inline-block for example.
body {
background-color: #444;
}
table {
border-collapse: collapse;
}
table,
th,
td {
border: 1px solid black;
font-size: 30px;
height: 40px;
text-align: center;
}
td {
width: 100px;
}
.goods td:nth-child(1){
color:green;
}
.goods span{
border: 1px solid green;
border-radius:15px;
padding-right: 5px;
width:13px;
cursor:pointer;
display: inline-block;
}
<table id="main">
<tr>
<td>K</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>*</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>*</td>
</tr>
<tr class="goods">
<td><span id="good1">a</span><span id="good2">b</span><span id="good3">c</span><span id="good4">d</span><span id="good5">e</span><span id="good6">f</span></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td><span id="ship">+</span></td>
</tr>
</table>
Just add display: inline-block; in span CSS
body {
background-color: #444;
}
table {
border-collapse: collapse;
}
table,
th,
td {
border: 1px solid black;
font-size: 30px;
height: 40px;
text-align: center;
}
td {
width: 100px;
}
.goods td:nth-child(1){
color:green;
}
.goods span{
border: 1px solid green;
border-radius:15px;
padding-right: 5px;
width:13px;
cursor:pointer;
display: inline-block;
}
<table id="main">
<tr>
<td>K</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>*</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>*</td>
</tr>
<tr class="goods">
<td><span id="good1">a</span><span id="good2">b</span><span id="good3">c</span><span id="good4">d</span><span id="good5">e</span><span id="good6">f</span></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td><span id="ship">+</span></td>
</tr>
</table>