Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Monday, March 14, 2016

How to have vertical line between table cells?

How to have vertical line between table cells?


In the code below I want to have vertical line between cells, What is the best way to do that? Somethings I tried are giving background color to table but its something same as giving border to table cell, then tried border-left or border-right but it will give one extra line outside cell. Here I want vertical line between cells. Please help.

table tr td {    background-color: #dedede;    color: black  }
this is first cell this is second cell this is third cell
this is fouth cell this is fifth cell this is sixth cell

Answer by Jeroen for How to have vertical line between table cells?


Adding a border to the right of the cells and a border to the left of the table should do it:

table tr td {    border-right: 1px solid #dedede;    color: black  }    table {    border-left: 1px solid #dedede;  }
this is first cell this is second cell this is third cell
this is fouth cell this is fifth cell this is sixth cell

Answer by Darren Sweeney for How to have vertical line between table cells?


Like this? This adds a border to every table tr td except the last one in the row

table tr td {    border-right: 1px solid blue;    color: black  }    table tr td:last-of-type {    border: none;  }
this is first cell this is second cell this is third cell
this is fouth cell this is fifth cell this is sixth cell

As mentioned by Daniel A. White - last-child also works:

table tr td:last-child {    border: none;  }  

Answer by DebRaj for How to have vertical line between table cells?


You can apply CSS border to your td and add cellspacing="0" cellpadding="0" to remove the gap between td

HTML:

this is first cell this is second cell this is third cell
this is fouth cell this is fifth cell this is sixth cell

CSS:

table{    padding: 0;    background-color: #dedede;    color: black;  }  table tr td{    padding: 5px;    border-right: 1px solid red;  }  table tr td:last-child{    border-right: none;  }  

Fiddle: https://jsfiddle.net/debraj/1ehubox9/

Answer by Ayoub Abid for How to have vertical line between table cells?


table tr td {     border-right: 1px solid black;  }  table tr td:nth-child(3n){      border-right: none;  }  

Answer by Mofarjul Molla for How to have vertical line between table cells?


table tr td+td {    border-left: 1px solid blue;    color: black  }
this is first cell this is second cell this is third cell
this is fouth cell this is fifth cell this is sixth cell


Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.