rwallace
rwallace

Reputation: 33589

Border around table but not cells

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.

Upvotes: 4

Views: 15115

Answers (2)

Jukka K. Korpela
Jukka K. Korpela

Reputation: 201866

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.

Upvotes: 5

falcon
falcon

Reputation: 357

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

http://jsfiddle.net/U2e8b/

Upvotes: 9

Related Questions