In this article, we will create a table using HTML. To create this table, we must know the tags required to create the table. At first, we will create the structure of the table and we will use attributes to design the table.
Approach: To create the table we have to use the <table> tag and we will use attributes of the <table> tag to design the table. The attributes that we will use to design the table are: cellspacing, cellpadding, border, bg color, etc.
Example:
<!DOCTYPE html>
< html >
< body bgcolor = "pink" >
< table bgcolor = "silver" align = "center"
border = "5" cellspacing = "5"
cellpadding = "5" >
< tr bgcolor = "purple" >
< caption align = "top" >
< h2 style = "color: #ff3300;" >
Train
</ h2 >
</ caption >
< th bgcolor = "magenta" >train number</ th >
< th bgcolor = "magenta" >departure</ th >
< th bgcolor = "magenta" >arrival</ th >
< th bgcolor = "magenta" >category</ th >
</ tr >
< tr >
< td >12267</ td >
< td >23:25</ td >
< td >05:15</ td >
< td >duronto</ td >
</ tr >
< tr >
< td >12426</ td >
< td >19:40</ td >
< td >05:05</ td >
< td >rajdhani</ td >
</ tr >
< tr >
< td >12019</ td >
< td >06:05</ td >
< td >13:15</ td >
< td >shatabdi express</ td >
</ tr >
</ table >
</ body >
</ html >
|
Output:

So using the attributes of the table tag, we can design the table.
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!