Skip to main content

HTML Table Tag Basics

Tables

Tables are very important to show data in the form of rows and columns. Tables make data more readable and easy to understand. A table consists of rows, columns and cells.

HTML Tags To Make A Table

As we know that there are basically three elements in a table, that is, rows, columns and cells. So, there are the following basic tags to create a table in an HTML web page:
  1. <TABLE> tag
  2. <TR> tag
  3. <TD> tag
  4. <TH> tag


 

<TABLE> Tag

<Table> tag is used to specify the start of a table. It also specifies some attributes of the table like ALIGN and BORDER attributes etc.
Example 1: <Table>                    => Table without a border.
Example 2: <Table border="1">     => Table with a border of width 1.
Example 3: <Table align="left" border="2">  => A left aligned Table with a border of width 2.

<TR> Tag

TR stands for TABLE ROW. As the name shows, <TR> tag is used to create a row in a table. A row is started by <TR> tag and is closed by </TR> tag. There are one or more <TD> or <TH> tags between <TR> and </TR> tags to create cells.

Example 1: <TR>
                <TD>1</TD>
                <TD>Ahmad</TD>
                </TR>
Output:

1 Ahmad

Example 2:
              <TR bgcolor="red">
              <TD>1</TD>
                <TD>Ahmad</TD>
               </TR>
Output
1 Ahmad


 

<TD> Tag

<TD> tag is used to create a cell. TD stands for TABLE DATA. In addition, the number of cells in a row will specify number of columns in a table. The data to be shown in a cell is placed between <TD> and </TD> tags.

Example 1: <TD>Ahmad</TD>
Example 2: <TD bgcolor="yellow">345</TD>
Example 3: <TD width="100">Nasir</TD>

<TH> Tag

<TH> tag is used to create a header row in a table. TH stands for TABLE HEADING.One <TH> tag makes one header cell. The data to be shown in header cell is placed between <TH> and </TH> tags.


Example 1: <TH> Roll No </TH>
Example 2: <TH bgcolor="yellow">Name</TH>
Example 3:
<TR>
<TH>Roll Number</TH>
<TH>Name</TH>
<Th Marks</TH>
</TR>
Output:

Roll Number Name Marks

A Complete Table Example Code and Output in Browser

HTML sample CodeOutput in web browser
<table border="4">
<tr>
<th>Roll Number</th>
<th>Name</th>
<th>Marks</th>
</tr>
<tr>
<td>1</td>
<td>Ahmad</td>
<td>700</td>
</tr>
</table>

Roll Number Name Marks
1 Ahmad 700


Comments

Popular posts from this blog

Explain Different Types Of Output Devices

Output devices Out put devices are used to display results of processing to the user. They perform the following functions:  Receive results from memory  Convert data into human readable form  Display results to the user Examples include: Monitor, printer, plotter, speaker, and multimedia projector. Different Types of Output Devices 1.    Monitor LCD Monitor CTR Monitor     Monitor is the most commonly used output device used to display results of processing. It has a TV like shape. Pictures on monitor are formed with picture elements called PIXEL. Monitors may be Monochrome that will display results in Black & White. Color Monitors are also available. They display results in multi colors. Monitor produces soft copy output. 2.    Printers Printers are used to produce hard copy out put. They print processing results on paper. Printers are divided into two main categories: · ...

Explain different types of storage devices

Topic: Explain different types of storage devices in Computer systems Storage Devices Storage devices are used to store data and instructions permanently. Storage devices are also called secondary storage devices / backing storage devices / external storage devices or auxiliary storage devices. Examples of storage devices include Hard Disk, CD and DVD etc. Why Secondary Storage Devices are Used? Secondary storage devices are used because: Primary memory(RAM) is volatile and temporary. When computer is switched off, all data in ram is erased. Storage devices can store large amounts of data and instructions permanently whereas Primary memory has less capacity of storing data. Types Of Storage Devices There are three main types of storage devices:  Magnetic Tape   Magnetic Disk   Optical Disk   Flash Memory storage devices 1. Magnetic Tape Magnetic tape is the oldest storage device. It is made of plastic coated with m...

Printer Types: Impact & Non-Impact Printers

Printers A printer is an output device that prints characters, symbols and graphics on paper. The printed output is called hard copy. Printers produce permanent documents. Print resolution is commonly measured in dots per inch (dpi). A printer with higher print resolution, that is, dpi will produce higher quality print outs, but it will cost higher too. Types of Printers Depending upon the mechanism of printing, there different types of printers, as follows: 1) Impact Printers 2) Non-Impact Printers 1. Impact Printers An impact printer works like a typewriter. It prints characters or images by striking a print hammer , a typeface or pins against paper and inked ribbon. We can say that impact printers do hit or impact an inked ribbon to print on a paper. Since, impact printers produce print outs by striking mechanism, they make a lot of noise, too. Print quality of impact printers is lower than print quality of non-impact printers. Printing cost or impact printers is l...