Tuesday, April 5, 2011

table with black outer, but grey inner border

Hello, I want to create a html table with a 1pt black outer border and the same border around every td.

Should look like this (only the borders, of course)

link text

I use

<table border="1" style="border-collapse:collapse; border-color:Black; border-style:solid; border-width:1pt">

As a result I get a black outer, but grey inner borders.

From stackoverflow
  • You could try implement something like this in your CSS stylesheet.

    .mytable
    {
    border-collapse:collapse; 
    border-color:#000000; 
    border-style:solid; 
    border-width:2px;
    }
    
    .mytable td
    {
    border-color:#cccccc; /*grey*/
    border-style:solid; 
    border-width:1px;
    }
    

    And something like this HTML:

    <table class="mytable">
        <tr>
            <td>Content</td>
        </tr>
    </table>
    

    Example here

    easwee : The css selector should be table.mytable - without space - or just .mytable. Like it is now you are targeting a .mytable class inside a table.
    Kyle Sevenoaks : Ah! thanks! Typos everywhere today :)
    Jan-Frederik Carl : Great! I thought it would work without speaking to the td´s, but that seems not to be so.
  • It don't works with 1 Pixel Border outside :-(

0 comments:

Post a Comment