Monday 20 June 2011

HTML: Tables

Okay, so, for formatting a page, getting it to look how you want, you'll probably need to use tables. Simple!
The <table> tag starts us off, and this has a bunch of attributes you can apply to it, such as:

align                        (center, left, right)
background             (for a file)
bgcolor                   (for a flat background color)
border                    (thickness)
bordercolor    
height
width
cellpadding             (this is to leave room between the edges of the cell and it's contents)
cellspacing              (this one is to leave room between separate cells)



Once you have your table, you'll want to put rows and columns in, presumably. To put in a new row, use the <tr> tag, while adding columns to the row is accomplished using the <td> tag.

To have a td cell span multiple columns or rows, use the attribute colspan="#" or rowspan="#"

Play around with some stuff and get comfortable, below is an example.







<table cellspacing="1" cellpadding="1" border="1" bordercolor="red">

<tr>
<td>      This is the contents of the first cell!        </td>
<td colspan="2">   ...and this is the second, spanning 2 columns. </td>
<td rowspan="2">   Getting messy with 2 rows   </td>
</tr>

<tr>
<td> Stuff!           </td>
<td> More stuff!   </td>
<td>  Last cell!     </td>
</tr>

</table>





turns out like this:


This is the contents of the first cell! ...and this is the second, spanning 2 columns. Getting messy with 2 rows
Stuff! More stuff! Last cell!

1 comment:

  1. I have a question, this html stuff is ging to be used in java programming?

    The question may be dumb but Im starting from zero, just installed eclipse and android developer kit XD.

    Thanks in advance.

    ReplyDelete