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

Converting Decimal Number system to Binary, Octal and Hexa Decimal with Examples and Vice Versa

Topics covered with examples: Converting Decimal Number system to Binary, Octal and Hexa Decimal with Examples and Vice Versa Number Systems in Computer Science and Conversion Method Conversion of Decimal number system to other  number systems Conversion of Decimal number system to binary number systems Conversion of Decimal number system to octal number systems Conversion of Decimal number system to hexadecimal number systems Conversion of    non-decimal Number system to Other non-decimal number system Conversion of other number systems to Decimal number system Conversion of binary number systems to Decimal number system Conversion of octal number systems to Decimal number system Conversion of  hexadecimal number systems to Decimal number system Q1. What is a Number System? What are different types of number system? Number system A number system is a set of digits, symbols and rules to express quantities in counting and c...

Use Microsoft Excel Online [ 2020 ] Free Spreadsheet

Topic: Use Microsoft Excel Online Free Spreadsheet How To Create Excel Worksheet Online Free Don't worry if you are to prepare a worksheet in Microsoft Excel and you have not purchased Microsoft Office software. You can use free online version of Microsoft Excel Online and create worksheets as you like. Following are the instructions on how to use Microsoft Excel Online. Use Microsoft Excel Online Free Spreadsheet Here are the easy steps to create  power calculator worksheet using Microsoft Excel Online free. 1. for this purpose you need to have a Microsoft Account. 2. Type  or copy paste the following address in your web browser's address bar https://office.live.com/start/excel.aspx Login To Your Microsoft Account. If you are not using any Microsoft account, please create an account now.  3. Login to your Microsoft account ( like abc@hotmail.com or xyz@hotmail.com) or read this post to Create a new Microsoft account in easy steps . Cho...

Convert Centimeters to Inches Python Programming | Python Program Conver...

YouTube Video Tutorial How to write a Python program to convert centimetres to inches Formula to convert centimetres to inches   Explanation of this Python Program This Python program prompts the user to enter a height in inches, converts it to centimeters, and then prints the converted value. It uses the conversion factor of 2.54 to perform the conversion and rounds the result to two decimal places before displaying it to the user. Here's an explanation of the provided Python program line by line: python inches = float ( input ( 'Enter the Height in inches to convert into centimeters:' )) This line prompts the user to enter a height in inches and assigns the entered value to the variable inches . The input() function is used to receive input from the user, and float() is used to convert the input into a floating-point number. python centimeters = inches * 2.54 This line calculates the equivalent value in centimeters by multiplying the inches variable by the conver...