17. XHTML MP Tables

To create a table in XHTML MP, you need the <table>, <tr> and <td> tags. Data in a cell is enclosed in <td></td> tags. Cells in the same row are enclosed in <tr></tr> tags. All rows are enclosed in <table></table> tags. So, <td></td> should be enclosed in <tr></tr> and <tr></tr> should be enclosed in <table></table>. The following XHTML MP example demonstrates how to create tables:


<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <title>Table in XHTML MP</title>

        <td>Cell A</td>
        <td>Cell B</td>
        <td>Cell C</td>

        <td>Cell D</td>
        <td>Cell E</td>
        <td rowspan="2">Cell F</td>

        <td colspan="2">Cell G</td>

The result of the above XHTML MP markup code in mobile phone emulators is shown below:

Sony Ericsson T610

Nokia Mobile Browser 4.0

WAP CSS is required to control the presentation aspect of a table. For example, if you want to add a border to the table or specify the color of a table cell, you have to make use of WAP CSS. To let you see clearly the effect of the rowspan and colspan attributes in the previous XHTML MP example, we specify black borders to the table cells with the WAP CSS border property, like this:

td {
  border: thin solid black

Sony Ericsson T610

Nokia Mobile Browser 4.0

Have a look at the "WCSS Border Properties" section of our WAP CSS tutorial if you are interested in learning more about the border properties of WAP CSS. In addition, the "WCSS Color Properties" section includes an example that illustrates how to set the foreground color and background color of table cells.

Previous Page Page 22 of 36 Next Page

Feedback Form (ExpandCollapse)

What do you think about this web page?

(Optional) Please provide us more details. For example, suppose you select option 2 above, can you tell us specifically what information is missing? You can also suggest anything that can help us improve this web page.

(Optional) Your name:

(Optional) Your email address:

Please enter again to confirm:

Due to the amount of messages we received, we may not be able to reply to all messages.

A button for going back to the top of this page