What is the equivalent of border="1" in CSS for table?
Asked Answered
E

6

17

I would like to use the CSS equivalent of border="1" through an equivalent stylesheet definition.

The border-width and border-style applies for the table but the cell borders which are given by border="1" are missing out.

Entomophilous answered 8/8, 2012 at 18:8 Comment(1)
Already answered a similar question in this topic -> #11189505Eponym
A
9

So this should be an easy answer but when you use CSS table and td its doesn't quite match border="1" 100% (But its very close)

enter image description here

My way uses this:

table { 
        border: 1px outset grey;
        padding: 1px 
  }

td { 
            border: thin inset grey;
            margin: 1;
    }
Agnomen answered 11/7, 2015 at 3:37 Comment(0)
M
8

Apply it to the td elements instead of table element.

Manipular answered 8/8, 2012 at 18:9 Comment(1)
Made this for my own answer, but you gave the answer before me, so: jsfiddle.net/mB594Rolling
H
1

CSS

td { border: solid 1px #PlaceColorHere }
Haugh answered 8/8, 2012 at 19:41 Comment(1)
Thank you. But I can not directly override TD because there are other definitions of it in the page which will be in jeopardy. KayKay's suggestion worked.Entomophilous
S
0

This works for me:

    table {
        border-width: 2px;
        border-style: groove;
    }
    td {
        border-width: 2px;
        border-style: inset;
    }
Sibling answered 6/9, 2016 at 17:37 Comment(0)
H
0

If you have some tables which want internal borders and some which don't, to differentiate, create a class "border1". The html changes to :

<table class="border1">

and add css :

.border1, .border1 th, .border1 td
{
    border: 1px solid black
}

which creates a border for the table as well as the cells inside.

Hispidulous answered 14/9, 2021 at 8:58 Comment(0)
C
0
  border-collapse: collapse;

cf. https://www.w3schools.com/css/css_table.asp

Compte answered 10/4 at 9:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.