Akira456
Akira456

Reputation: 5

Cellspacing and cellpadding in HTML

I want to know about cellspacing and cellpadding in HTML

I was coding in vscode so when i tried typing cellspacing it didn't show me as a table attribute.I just started learning HTML so can someone help me in this. This is what I mean Same problem for cellpadding too. Is there any other way to do this?

Upvotes: -3

Views: 719

Answers (2)

Abhay Dedkawala
Abhay Dedkawala

Reputation: 503

cellpadding attribute is used to set padding between cells.

Same as style padding :

td {
   padding: 10px;
}

<table border="1" cellpadding="10">
  <tr>
    <td>1</td>
    <td>2</td>
    <td>3</td>
  </tr>
  <tr>
    <td>4</td>
    <td>5</td>
    <td>6</td>
  </tr>
  <tr>
    <td>7</td>
    <td>8</td>
    <td>9</td>
  </tr>
</table>

while cellspacing attribute is used to set space between cells.

<table border="1" cellspacing="10">
  <tr>
    <td>1</td>
    <td>2</td>
    <td>3</td>
  </tr>
  <tr>
    <td>4</td>
    <td>5</td>
    <td>6</td>
  </tr>
  <tr>
    <td>7</td>
    <td>8</td>
    <td>9</td>
  </tr>
</table>

cellpadding and cellspacing attribute in single code.

<table border="1" cellpadding="10" cellspacing="10">
  <tr>
    <td>1</td>
    <td>2</td>
    <td>3</td>
  </tr>
  <tr>
    <td>4</td>
    <td>5</td>
    <td>6</td>
  </tr>
  <tr>
    <td>7</td>
    <td>8</td>
    <td>9</td>
  </tr>
</table>

Upvotes: 0

iorgu
iorgu

Reputation: 3053

cellpadding is deprecated obsolete, that's why it won't show up in vscode.

Defines the space between the content of a cell and its border. This attribute is obsolete: instead of using it, apply the padding CSS property to the <th> and <td> elements.

Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table#cellpadding

Upvotes: 1

Related Questions