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

Advantages and Disadvantages of Ring Network Topology

Topic: Advantages and Disadvantages of Ring Network Topology alongwith detailed working of Ring topology What Do You Mean by Ring Topology? In Ring topology, each computer is connected to the next computer such that last computer is connected to the first. Every computer is connected to next computer in the ring. Each computer retransmits what it receives from the previous computer. Suppose, computer A needs to send data to computer D. Now the computer A sends data to computer B. As computer B is not the destination computer, so it will retransmit data to computer C. Finally, Computer C will transfer data to computer D, the destination computer. When a node sends a message, the message is processed by each computer in the ring. If a computer is not the destination node, it will pass the message to the next node, until the message arrives at its destination. Advantages of Ring Network Topology 1. It is relatively less expensive than a star topology network. 2. In a Rin

Types Of e-Commerce

Types/Categories/Modes of e-commerce. There are three main types of e-commerce as follows: 1) Business To Consumer (B2C) B2C ecommerce consists of selling goods and services to individual consumers. In this type, consumers or customers can visit the website and purchase goods online. The website will have a StoreFront. This storefront will show product details, pictures and a shopping cart. Shopping cart is used to collect items to purchase. Advantages of B2C e-commerce B2C e-commerce has the following advantages: * Shopping can be faster and more convenient. * Offerings and prices can change instantaneously. * Broadband telecommunications will enhance the buying experience. 2) Business To Business (B2B) B2B e-commerce takes place between two businesses. One business provides services to other business. Examples of B2B include: Online Advertisement, recruiting, sales, marketing, technical support and training. For eample, some companies provide online purchasing

Electricity Bill Calculator Formulas in Excel

Today, we will discuss How to create an Electricity Bill Calculator Worksheet by using Electricity Bill Calculator Formulas in Excel . The following formulas will be used in Electricity Bill Calculator Worksheet: Q: Prepare a worksheet according to the following instructions: Create a worksheet in MS Excel according to the requirements Enter sample data of Electricity units consumed by customers in a city Apply formula to calculate Units Consumed Apply formula to calculate Electricity Charges Apply formula to calculate Surcharge Apply formula to calculate Bill Payable Note: Every formula will start from  =  Units Consumed Formula=D5-C5 Electricity Charges Formula=IF(E5>200, E5*15,IF(E5>100, 1000+(E5-100)*12, E5*10)) SURCHARGE FORMULA = IF(F5>5000, F5*5%,IF(F5>1000, F5*3%, 0)) BILL PAYABLE FORMULA = SUM(F5:G5) Download Excel Electricity Bill Calculation Worksheet Free  Image for Electricity Bill Calculator Formulas in Excel Softw