Web Development

  Homes arrow Web Development arrow Chapter 10: Tables
 Webmaster Tools
Base64 Encoding 
Browser Settings 
CSS Coder 
CSS Navigation Menu 
Datetime Converter 
DHTML Tooltip 
Dig Utility 
DNS Utility 
Dropdown Menu 
Fetch Content 
Fetch Header 
Floating Layer 
htaccess Generator 
HTML Encoder 
HTML Entities 
IP Convert 
Meta Tags 
Password Encryption
Password Strength
Pattern Extractor 
Ping Utility 
Pop-Up Window 
Regex Extractor 
Regex Match 
Scrollbar Color 
Source Viewer 
Syntax Highlighting 
URL Encoding 
Web Safe Colors 
Forums Sitemap 
Weekly Newsletter
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Contact Us 
Site Map 
Privacy Policy 
  >>> SIGN UP!  
  Lost Password? 

Chapter 10: Tables
By: Developer Shed
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating:  stars stars stars stars stars / 0

    Table of Contents:

    Rate this Article: Poor Best 
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article




    Example of a Table...

    What are tables used for?
    Tables are used to make data easier to interpret or to just give your document more impact.

    <table border=4>
    <th>What are tables used for?</th>
    <td>Tables are used to make data easier to interpret or to just
    give your document more impact.</td>

    Tables are one of the most challenging things to code with HTML. It isn't very hard, it just takes a while to get the hang of. Tables start with the <table> tag, and usually contain the border=n attribute within the opening tag. If the border=0, than the table's border is invisible. Usually when you do not use the border attribute the table border will become invisible. This is useful when you want to align text in rows and columns, but don't want a table border around it. border=1 is a thin border. border=2 is a little thicker, border=3 a little more thick.. and so on. The table MUST end with a </table> tag, or the table will not appear at all!

    Example of tables with borders...

    This table has a border of 0.
    <table border=0>
    <td>This table has a border of 0.</td>
    This table has a border of 3.
    <table border=3>
    <td>This table has a border of 3.</td>

    Each row within the table is defined by the opening
    <tr> tag and the optional </tr> closing tag. Within each table row are table cells, which are defined by the <td> opening and </td> closing tags. Most table rows contain more than one cell. Many times, you will need a heading for a column of cells of the first row. To do this, you will use the <th> opening and </th> closing tag. The table heading tag makes the text in that cell BOLD and CENTERED. You only need use the heading cells when necessary.

    Example of a table with multiple rows and columns...

    Heading A Heading B Heading C
    Cell A Cell B Cell C
    Cell D Cell E Cell F

    <table border=2>
    <th>Heading A</th><th>Heading B</th><th>Heading C</th>
    <td>Cell A</td><td>Cell B</td><td>Cell C</td>
    <td>Cell D</td><td>Cell E</td><td>Cell F</td>

    But what if you want your table to look like the following?

    Heading A Heading B Heading C
    Cell A & D Cell B Cell C
    Cell E Cell F

    <table border=2>
    <th>Heading A</th><th>Heading B</th><th>Heading C</th>
    <td rowspan=2>Cell A & D</td><td>Cell B</td><td>Cell C</td>
    <td>Cell E</td><td>Cell F</td>

    Notice how the rowspan=2 attribute was added. This allows that cell to span two rows. If you want a cell to span more than column, use the colspan=n attribute. Also, you may wish to use the ALIGN and VALIGN attributes to align the contents of cells. If you wish to change the horizontal alignment of the contents of a certain cell, add ALIGN=LEFT, ALIGN=CENTER, or ALIGN=RIGHT to the opening <td> tag. If you wish to change the vertical alignment of the contents of a cell, use the VALIGN=TOP, VALIGN=MIDDLE, or VALIGN=BOTTOM attributes. You may also want to try out the WIDTH=n% attribute, to change the width of a table or a cell.

    Example of ALIGN attributes within a table...

    Left Alignment Center Alignment Right Alignment

    <table border=1 width=100%>
    <td align=left>Left Alignment</td>
    <td align=center>Center Alignment</td>
    <td align=right>Right Alignment</td>

    Your own HTML page...

    Right click on the image in the centre of the black-bordered box below, and select "Save Image As" / "Save Picture As", or similar. Save it as "phxsuns.jpg" in the same directory where your home page "Home.htm" is stored.

    Tables can be used without borders, to align images and text next to each other. Change the heading of your home page to a table, like this:

    <head><title>My Home Page</title></head>
    <!-- The body starts here - and a background image is loaded -->
    <body background="bgnd.gif">

    <!-- This is a table: 3 columns, 1 row, no border -->
    <table border=0 width=100%>
    <!-- Beginning of the row -->
    <!-- Beginning of the first cell -->
    <td align=center>
    <!-- The first cell contains an image -->
    <img src="fraidbut.gif">
    <!-- End of the first cell -->
    <!-- Beginning of the second cell -->
    <td align=center>
    <!-- The second cell contains the original heading -->
    <font color="Blue"><h1>YOURNAME's Home Page</h1></font>
    <!-- End of the second cell -->
    <!-- Beginning of the third cell -->
    <td align=center>
    <!-- The third cell contains an image -->
    <img src="fraidbut.gif">
    <!-- End of the third cell -->
    <!-- End of the row -->
    <!-- End of the table -->

    <!-- This is a horizontal line -->

    Save the text file as "Home.htm".

    << Chapter 9


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More Web Development Articles
    More By Developer Shed



    - On Page SEO for New Domains
    - Improve Your Site`s Speed
    - Safari Books Online Review
    - Creating an Estore From the Ground Up
    - Most Common SEO Mistakes Developers Make
    - Making the Most of Your Titles and Meta Desc...
    - Five Ways Using Flash Can Damage Your Site
    - A Web Designer`s Guide to Colors
    - Use Webstarts to Create a Free Site
    - More Than Just Looks. How Your Web Design C...
    - How to Design Content Pages
    - Mint Review
    - Make Your WordPress Website Look Professional
    - How to Create a Mobile Web Site
    - Meta Tags: Still Useful?

    Developer Shed Affiliates


    © 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap