Since: DataTables 2.0

Get / set the table's caption.


HTML tables have an optional element called caption which can be used to show the title of a table to the end user. This can greatly enhance accessibility since it can give a summary of the contents of the table without the end user needing to read the surrounding text.

This method is provides to control the contents of a DataTables' caption element.


function caption()


Get the contents of the caption element for the table.

Note that if the API instance references multiple tables, only the first table in the collection will be considered for the getter.


Contents of the caption element. Will be null if there is no caption.

function caption( set [, side ] )


Set the contents of the caption element. If the table doesn't have a caption element, one will be created automatically.

Note that is the API instance references multiples tables, the caption will be set for all tables referenced.


DataTables API instance for chaining.


Set the table's caption:

var table = new DataTable('#myTable');

table.caption('Table 1: Class averages');

Set the table's caption and display at the bottom of the table:

var table = new DataTable('#myTable');

table.caption('Table 2: Year averages', 'bottom');


The following options are directly related and may also be useful in your application development.