Google
HTML COURSE FOR EASY LEARNING
Homepage lesson-2 lesson-3 lesson-4 lesson-5 lesson-6 lesson-7 lesson-8 lesson-9 lesson-10
previous

next

This course is developed for the  online community who are willing to learn online in the leisure periods,  the web designing course,and this is the first step in  learning the web designing. Every one can easily  learn this  by sitting before their personal computers and practice themselves.ok wish you good luck.


LSESSON-6 FORMATTING TABLES

The Important attributes in formatting the Tables

1)The align attribute:

The align attribute with table tag defines the place of table in the webpage.(Left or Right) The align attribute with <td> tag defines the place of content in the cell and with <tr> tag the alignment of content in the row.

2)The valign attribute:

This attribute is used with cell tags(<td> or <th>). Vertical alignment of text content in the cell is defined with this attribute.VALIGN=top|middle|bottom|baseline vertical align, ex:- <td valign=�left�>
Used to align all text in the row or cell to the top, middle or bottom of the cell, and also to specify that all cells should line up with the same baseline.

3)BORDER="value"

unlsess the border is set at more than zero the table will not have border. The border value defines the thickness of the border. This attribute is used with table tag and table row tag (<tr>) and table cell tag (<td>)

4)CELLSPACING=value

This defines the space, in pixels, inserted between individual cells in a table.

5)CELLPADDING=value

This defines the space, in pixels, inserted between the border of the cell and the contents of the cell.

6)WIDTH=value|percent

This defines the width of the table or width of cell or width of a row, either in pixels or in terms of percentage of the document width.

6)HEIGHT=value|percent

This defines the HEIGHT of the table or HEIGHT of cell or HEIGHT of a row, either in pixels or in terms of percentage of the document HEIGHT.

7)NOWRAP


Inclusion of this attribute specifies that lines within the cell should not be broken (wrap) to fit the cell width.
TRY THIS EXAMPLE:
<TABLE BORDER=1> <TR> <TH>HEADING</TH> <TH>HEADING</TH> </TR> <TR VALIGN="BOTTOM" ALIGN="CENTER"> <TD HEIGHT=35>Ganesh</TD> <TD NOWRAP>Krishna is a prominent personality in Mahabharatha .</TD> </TR> <TR VALIGN="TOP"> <TD WIDTH=200 ALIGN="RIGHT">Hanuman</TD> <TD HEIGHT=35>Rama</TD> </TR> </TABLE>
HEADING HEADING
Ganesh Krishna is a prominent personality in Mahabharatha
Hanuman Rama


8)Merging cells


The next step in creating your desired table is to merge cells where required. You can combine cells so that they span 2 or more columns, or 2 or more rows. This is done using the COLSPAN and ROWSPAN attributes as follows:
COLSPAN=value
Used to specify how many columns a cell should span.
ROWSPAN=value
Used to specify how many rows a cell should span.
Note down the following example
<table width="100%" border="1" bordercolor="indigo"> <tr><td> first cell</td><td>second cell</td><td> third cell</td></tr> <tr><td> fourth cell</td><td>fifth cell</td><td> sixth cell</td></tr> <tr><td> seventh cell</td><td>eighth cell</td><td> nineth cell</td></tr> <tr><td> tenth cell</td><td>11th cell</td><td> 12th cell</td></tr> <tr><td> 13th cell</td><td>14th cell</td><td> 15th cell</td></tr> <tr><td> 16th cell</td><td>17th cell</td><td> 18th cell</td></tr> <table/>
first cellsecond cell third cell
fourth cellfifth cell sixth cell
seventh celleighth cell nineth cell
tenth cell11th cell 12th cell
13th cell14th cell 15th cell
16th cell17th cell 18th cell

The above is a simple table and now you merge first,second ,third cells and
4th,7th,10th cells and 14th,15th,17th and 18th cells as follows:
<table width="100%" border="1" bordercolor="indigo"> <tr><td colspan="3"align="center">mergedcell</td></tr> <tr><td rowspan="3"align="center"> mergedcell</td><td>fifth cell</td><td> sixth cell</td></tr> <tr><td>eighth cell</td><td> nineth cell</td></tr> <tr><td>11th cell</td><td> 12th cell</td></tr> <tr><td> 13th cell</td><td colspan="2" rowspan="2"align="center">mergedcell</td></tr> <tr><td> 16th cell</td></tr> <table/>
merged
merged cellfifth cell sixth cell
eighth cell nineth cell
11th cell 12th cell
13th cellmerged cell
16th cell

9)Formatting columns

Using <COL> or <COLGROUP> tags you can now specify the text alignment for table columns. Essentially this element lets you format cells in a column, in the same manner that <TR> lets you format cells in a row. You should use <COLGROUP> to format 2 or more columns at a time and the <COL> element to format individual columns. The <COL> element should always be contained within <COLGROUP></COLGROUP> tags. The attributes are explained below:
Example:

<TABLE BORDER=1 WIDTH=80%> <COLGROUP> <COL ALIGN="left"> <COL ALIGN="right" VALIGN="bottom"> </COLGROUP> <COLGROUP SPAN=2 ALIGN="center" VALIGN="top"> </COLGROUP> <TR> <TH>SCIENCE</TH> <TH>MATHS</TH> <TH>HISTORY</TH> <TH>ARTS</TH> </TR> <TR> <TD HEIGHT=35>Ganesh</TD> <TD>RAGHU</TD> <TD>VENKAT</TD> <TD>Krishna</TD> </TR> <TR> <TD HEIGHT=35>Hanuman</TD> <TD>SATYAM</TD> <TD>ROHIT</TD> <TD>Rama</TD> </TR> </TABLE>
SCIENCE MATHS HISTORY ARTS
Ganesh RAGHU VENKAT Krishna
Hanuman SATYAM ROHIT Rama

10)TABLE COLOURS


The color attribute with tables is two types one is bgcolor and the other is bordercolor. The bgcolor attribute defines the background color of the table or cell or a row or a column as mentioned in the code. The bordercolor is again three types one is simple bordercolor and the remaining two attributes are "bordercolordark" and "bordercolorlight". The bordercolordark and bordercolorlight are used along with bordercolor attribute and when these three attributes are used the border appears in a different style with 3d effect.Follow the example here:-
<table border="3"bgcolor="00ffff" bordercolor="indigo"width="100%"height="100"> <tr><th>SCIENCE</Th> <th>ARTS</th></tr> <tr bordercolor="red"bgcolor="green"> <td>ganesh</td> <td>krishna</td></tr> <tr bordercolor="red"bgcolor="green"><td bordercolor="yellow">Hanuman</td><td bgcolor="White">Rama</td></tr> <tr bordercolor="orange" bordercolordark="blue" bordercolorlight="white"><td>Venkat</td><td>Abhiram</td></tr> </table>
SCIENCEARTS
ganeshkrishna
HanumanRama
VenkatAbhiram


11)background images


the background attribute helps to set the background of the table with an image the background attribute is written as follows:- <table background="imagename with location">
Example of code:-

<table width="100%"border="1" background="f1.jpg"> <tr><th width="50%">heading1</th> <th width="50">heading2</th> </tr> <tr> <td>cell1</td> <td>cell2</td></tr> <tr><td>cell3</td> <td>cell4</td></tr> </table>
heading1heading2
cell1cell2
cell3cell4

Note:font size and color of the text can be decided only with each individual cells.(ie. with <td> tags only)The table creation chapter is closed and now you must be able to create webpages with text and tables. If not I once again study the first four chapters and only after satisfactory completion you to to next chapter.



previous

end of LESSON-6

next

Copyright © easyfreehtml. All rights reserved.
Hosted by www.Geocities.ws

1