Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Border around table but not cells

Tags:

html

Is there a way to display an HTML table with a border around the entire table but not around the cells within it? The table border attribute is deprecated in favor of CSS, but both the border attribute and the suggested CSS replacement outline the individual cells as well as the table.

like image 506
rwallace Avatar asked Dec 08 '22 07:12

rwallace


2 Answers

<table style="border:1px solid;">

http://jsfiddle.net/U2e8b/

like image 171
falcon Avatar answered Dec 31 '22 02:12

falcon


The HTML attribute border draws borders around the entire table as well as around each cell. The latter can be prevented using the attribute rules (which controls the existence of borders around cells) with value none:

<table border=1 rules=none>

Although the questions is not tagged with “css”, you might be interested in a CSS approach. The key issue is then to set the border property table element only. This does not create borders around cells. So you could use, in CSS,

table { border: solid thin gray }

for example, if you want all tables to have borders.

However, if some other style sheets set borders around cells and you don’t want them, you need to analyze how they do that and either edit them or write your own rules that have higher specificity and set e.g. border: none on th and `td+ elements.

like image 44
Jukka K. Korpela Avatar answered Dec 31 '22 02:12

Jukka K. Korpela