How to make HTML table cells editable?

Spread the love

Sometimes, we want to make HTML table cells editable.

In this article, we’ll look at how to make HTML table cells editable.

How to make HTML table cells editable?

To make HTML table cells editable, we add the contenteditable attribute.

For instance, we write

<table>
  <tr>
    <td><div contenteditable>I'm editable</div></td>
    <td><div contenteditable>I'm also editable</div></td>
  </tr>
  <tr>
    <td>I'm not editable</td>
  </tr>
</table>

to add the contenteditable attribute to the editable divs inside the td cells to make then editable.

Conclusion

To make HTML table cells editable, we add the contenteditable attribute.

Leave a Reply

Your email address will not be published. Required fields are marked *