Skip to main content

Add a table to an HTML page

Build this trail guide on the About page of the Trail Notes practice website. In Phoenix Pro, you'll work in Live Preview. In Community (free), you'll edit the HTML beside it. Both methods work on Windows, macOS, and Linux.

Open the finished table on its own.

Click or tap any screenshot to open it full size.

1. Open the About page​

If you already have Trail Notes open, click about.html and start adding the table.

  1. Download the Trail Notes practice website. On Windows, right-click the ZIP and choose Extract All. On macOS, double-click the ZIP in Finder. On Linux, open it in your archive manager and choose Extract.

  2. In Phoenix Code, choose File → Open Folder…. Select the folder that contains about.html, contact.html, and index.html. If you see another first-website folder inside the first one, open that inner folder. In the file list on the left, click about.html.

    The first-website file list with about.html selected above contact.html and index.html.

  3. Look for Small walks. Good stories. in Live Preview. If the preview is closed, click the lightning bolt on the right. If Phoenix Code asks whether you trust the authors of this practice project, click Trust & Execute Preview for first-website. If you see the home page, click about.html again.

You'll put the table between the bulleted list and Visit the contact page.

2. Add the first trail​

Insert the table in Design Mode​

Watch the table take shape in Live Preview. The recording starts with about.html open in Design Mode and ends with both trails saved.

  1. Click the maximize icon in the Live Preview toolbar to enter Design Mode. If the pen is gray, click it. The orange pen means Edit Mode is on.

  2. Click Visit the contact page once to select the link. On the blue toolbar that appears, click + (Insert Element). Choose Before so the table will sit above the link.

  3. Type table in Search elements. Click Table, the result with the grid icon. It adds two column headings and one row.

    Insert Element with Before selected, table in the search field, and the Table result with a grid icon above the selected Contact link.

  4. On the new table's blue toolbar, click table to open Element Properties. Under Class, click Add a class…, type trail-table, and press Enter. If the input is closed, click + to open it. The headings appear on a pale green band and the distances line up on the right. Close Element Properties with its ×.

    Element Properties for the table shows trail-table in the Class field. The column headings and cells now span the width of the table.

  5. Double-click Header 1, select its text, type Trail, and press Enter. Change Header 2 to Distance the same way. In the row below, change Cell 1 to Pine Loop and Cell 2 to 2 km.

  6. Give the table a caption. Click Trail once, then click the up arrow (Select Parent) on the blue toolbar twice. The toolbar label changes from th (one heading) to tr (one row) to thead (the heading section).

  7. With thead selected, click +, choose Before, and type caption in Search elements. Click Create <caption>. Double-click the new words caption content in the illustrated banner, replace them with Trail distances, and press Enter.

    The Insert Element panel offers Create caption with Before selected and both column headings outlined together.

  8. Click Save File beside the file list. Check that Trail distances appears beside the hills and the first row reads Pine Loop and 2 km.

Using an older Trail Notes project and seeing a plain table?

Open the current practice stylesheet. Find the comment /* Trail table */ near the end. Copy from that comment through the last closing brace, }. In Phoenix Code, paste those rules at the end of your own styles.css and choose File → Save File. Click about.html again to see the design. The banner uses the practice site's images/trail.svg illustration.

3. Change a cell and add a row​

A cell is one entry in the table. You'll change the first distance and give the second trail its own row.

Duplicate a row in the preview​

  1. Double-click 2 km, change it to 3 km, and press Enter.

  2. Click Pine Loop once. The blue toolbar shows td, the tag for a cell. Click the up arrow (Select Parent) once. Check that the toolbar now shows tr, the tag for the whole row.

  3. Click Duplicate, the overlapping squares with a plus on the blue toolbar. A second row appears with the same trail and distance.

    The blue toolbar shows tr above the selected Pine Loop row. Duplicate is the overlapping-squares button between the pencil and the trash can.

  4. In the second row, double-click Pine Loop, change it to Lake Walk, and press Enter. Change its distance to 4 km the same way.

  5. Click Save File. Click the pen button to turn off Edit Mode and see the finished table.

Check the two rows in Live Preview. The first should read Pine Loop — 3 km, and the second Lake Walk — 4 km. You can also open the saved about.html in a browser. The Contact link should still be directly below the table.

The saved About page shows an illustrated Trail distances banner, Pine Loop at 3 km and Lake Walk at 4 km. The distances are aligned above the Contact link.

If you're editing a README.md file, follow Make a Markdown table with aligned columns.