Creating tables in Drupal

Inserting a New Table

If you're using Drupal and have the FCK Editor, CK Editor or another similar editor installed then when you're in edit mode, you'll see an 'insert table' button that unsurprisingly looks like a table!

If you click this then you will be given the option to insert a table with the following properties:

Drupal table properties

Some of these such as rows and columns are obvious.  Others are less so.  We would recommend that you change some of the default values in order to get your table working properly.  Here's what the values do:

Width This can either be in pixels (px) or percent. 
Normally 100 percent is the best setting as this will automatically expand to fit the space where the table is.
Height If you want the table to be a fixed height, you can enter this here.  Normally it's best to leave this blank and the table's height will then automatically expand to fit the content.
Border Size If you don't want borders to be visible (as in the table here) then change the Border Size to 0.  To make extra thick borders, increase this number.
Cell Spacing &
Cell Padding
Cell Spacing is the spacing between different cells.
Cell Padding is the padding between the contents of a cell and the edge of the cell.
If you'd like your contents to be more spread out, use a number (normally 5 - 10) in either of these to achieve this.
This table has Cell Spacing 1 and Cell Padding 5.
Alignment This is where the table as a whole is positioned on the page. 
If your table has a 100% width, modifying this setting won't do anything.

 

Editing Drupal Tables

If you've already created a table and want to edit it, there are several controls available which allow you to do this.  If you right click over the table (Apple + click on a Mac), then a drop-down menu appears which lets you easily add and delete rows and columns, as well as providing a range of other options.

Edit a table with the CK Editor

If you wish to modify an individual cell in your Drupal table, then from the Cell menu, choose the last item on the list 'Cell Properties'.  This allows you several options, including the following:

 

Word Wrap If you have a column that should always remain on one line (e.g. short titles), then you can change Word Wrap to 'no' and it will then keep all the words on the same row.
Horizontal Alignment This lets you determine if the contents of a cell is left, right or centrally aligned.
Vertical
Alignment
By default in HTML a table is middle aligned vertically, this means that the contents of a table float to the vertical middle of each cell.  You may wish to change this to 'Top' to prevent this from happening for a certain cell.
Background
Colour
Give the cell a background colour.
Border
Colour
Give the cell a border colour.

 

If you've found this inserting tables in Drupal tutorial useful, then you may also be interested in our Drupal end-user guide.