Simple Example of Editable Table in HTML5

In this tutorial, I will let you know, creating editable table in html5, bootstrap and jquery. It’s the magic of HTML5. You can provide an inline editable option on any HTML element using an editable attribute contenteditable=”true”.

It’s very easy and simple to use with HTML elements. Here, we are creating html table editable on client side. You can also make editable HTML table server side using php and ajax.

The user can make the table or a specific table cell editable with the help of the HTML “contenteditable” attribute.

You just need to add contenteditable=”true” attribute on any div, td, or any html element that want to make editable element, and user can change the content of the editable element.

Syntax:

contenteditable="true"

I am creating table list and able to make td content inline editing with help of jQuery.

Also checkout other related tutorials,

Simple Example of Editable Table in HTML5

Let’s create a HTML table and make the td editable. The "contenteditable" attribute inside the "<td>" tag of the specific cell you want to edit:

<table id="employee_grid" class="table table-condensed table-hover table-striped bootgrid-table" width="60%" cellspacing="0">
   <thead>
      <tr>
         <th>Name</th>
         <th>Salary</th>
         <th>Age</th>
      </tr>
   </thead>
   <tbody>
      <tr data-row-id="1">
         <td contenteditable="true">Tiger Nixon</td>
         <td contenteditable="true">320800</td>
         <td contenteditable="true">61</td>
      </tr>
      <tr data-row-id="2">
         <td contenteditable="true">Garrett Winters</td>
         <td contenteditable="true">170750</td>
         <td contenteditable="true">63</td>
      </tr>
      <tr data-row-id="8">
         <td contenteditable="true">Rhona Davidson</td>
         <td contenteditable="true">327900</td>
         <td contenteditable="true">55</td>
      </tr>
   </tbody>
</table>
After that you are able to edit column.

Result :

How to Make a Whole Table Editable in HTML?

To make the complete table editable, use the “contenteditable” attribute in the “<table>” element:

<table id="employee_grid"  contenteditable="true" class="table table-condensed table-hover table-striped bootgrid-table" width="60%" cellspacing="0">
   <thead>
      <tr>
         <th>Name</th>
         <th>Salary</th>
         <th>Age</th>
      </tr>
   </thead>
   <tbody>
      <tr data-row-id="1">
         <td>Tiger Nixon</td>
         <td>320800</td>
         <td>61</td>
      </tr>
      <tr data-row-id="2">
         <td>Garrett Winters</td>
         <td>170750</td>
         <td>63</td>
      </tr>
      <tr data-row-id="8">
         <td>Rhona Davidson</td>
         <td>327900</td>
         <td>55</td>
      </tr>
   </tbody>
</table>

The entire table is now editable. You can change or delete any table cell’s data.

Demo & Download Code

Please feel free to send queries to me using below comment section.

One thought on “Simple Example of Editable Table in HTML5

  1. Just editing the cells … isn’t it slightly tasteless :-)?

    As asked in another post, may I ask that here too?

    This will turn interesting with three ingredients :
    – start with an empty grid with just the first (empty) row
    – append rows on demand
    – when the input is finished, treat this grid as a sort of array to make an INSERT into a MySQL table all these rows of records.

    Can you kindly hint how to approach this? Or implement it in the tutorial? Thank you

Leave a Reply

Your email address will not be published.