Basic Table Elements and Attributes part 1
Table of Content:
We already discuss about these below attributes
- The
align
Attribute - The
bgcolor
Attribute - The
border
Attribute
The <table>
Element Creates a Table
- The
align
Attribute - The
bgcolor
Attribute - The
border
Attribute - The
cellpadding
Attribute - The
cellspacing
Attribute - The
dir
Attribute - The
frame
Attribute - The
rules
Attribute - The
summary
Attribute - The
width
Attribute
The <tr>
Element Contains Table Rows
- The
align
Attribute - The
bgcolor
Attribute - The
char
Attribute - The
charoff
Attribute - The
valign
Attribute
The <td>
and <th>
Elements Represent Table Cells
- The
abbr
Attribute - The
align
Attribute - The
axis
Attribute - The
bgcolor
Attribute - The
char
Attribute - The
charoff
Attribute - The
colspan
Attribute - The
headers
Attribute - The
height
Attribute - The
nowrap
Attribute - The
rowspan
Attribute - The
scope
Attribute - The
valign
Attribute - The
width
Attribute
- Adding a
<caption>
to a Table - Spanning Columns Using the
colspan
Attribute - Spanning Rows Using the
rowspan
Attribute - Splitting Up Tables Using a Head, Body, and Foot
- Grouping Columns Using the
<colgroup>
Element - Columns Sharing Styles Using the
<col>
Element - Nested Tables
The cellpadding
Attribute
The cellpadding attribute is used to create a gap between the edges of a cell and its contents.
cellpadding="5" or cellpadding="2%"
This attribute has been replaced by the padding
property in CSS.
HTML Code
Month | Earning |
---|---|
January | $100 |
Live Preview
The cellspacing
Attribute
The cellspacing attribute is used to create a space between the borders of each cell.
cellspacing="6" or cellspacing="2%"
HTML Code
Month | Earnning |
---|---|
January | $100 |
Live Preview
The cellspacing attribute of <table> is not supported in HTML5.
The cellspacing attribute specifies the space, in pixels, between cells.
This attribute has been replaced by the margin property in CSS.
The dir
Attribute
The dir attribute is used to set the base direction of text for display. It is essential for enabling HTML in right-to-left scripts such as Arabic, Hebrew, Syriac, and Thaana. Numerous different languages are written with these scripts, including Arabic, Hebrew, Pashto, Persian, Sindhi, Syriac, Dhivehi, Urdu, Yiddish, etc.
he dir attribute is supposed to indicate the direction of text that is used in the table. Possible values are ltr for left to right text and rtl for right to left
dir="rtl"
HTML Code
This is a example of dir="rtl"
Month | Earnning |
---|---|
January | $100 |
Live Preview
The frame
Attribute
The frame attribute was used to define the visible borders of a table. It is now deprecated and should no longer be used. frame , with greater control than the border attribute.
The following table shows the possible values for the frame attribute.
Value | Purpose | Example |
void | No outer border (the default) | <table frame="void"> |
above | A border on the top only | <table frame="above"> |
below | A border on the bottom only | <table frame="below"> |
hsides | A border on the top and bottom | <table frame="hsides"> |
lhs | A border on the left side of table | <table frame="lhs"> |
rhs | A border on the right side of table | <table frame="rhs"> |
vsides | A border on the left and right sides of table | <table frame="vsides"> |
box | A border on all sides | <table frame="box"> |
border | A border on all sides | <table frame="border"> |
Support for the frame attribute is not perfect across browsers, and its role has been replaced by the CSS
border
property, which can give better results.
Now we will discuss by By this examples
Name | Food |
---|---|
Jakir | Rasgola |
Sabir | Masala Dosa |
Sourav | Biryani |
Rohan | Chole Batura |
Rumman | Birayani |
Let's start
Example: 1 <table frame="void">
No outer border (the default)
Name | Food |
---|---|
Jakir | Rasgola |
Sabir | Masala Dosa |
Sourav | Biryani |
Rohan | Chole Batura |
Rumman | Birayani |
Live Preview
Example: 2 <table frame="above">
A border on the top only.
Name | Food |
---|---|
Jakir | Rasgola |
Sabir | Masala Dosa |
Sourav | Biryani |
Rohan | Chole Batura |
Rumman | Birayani |
Live Preview
Example: 3 <table frame="below">
A border on the bottom only.
Name | Food |
---|---|
Jakir | Rasgola |
Sabir | Masala Dosa |
Sourav | Biryani |
Rohan | Chole Batura |
Rumman | Birayani |
Live Preview
Example: 4 <table frame="hsides">
A border on the top and bottom.
Name | Food |
---|---|
Jakir | Rasgola |
Sabir | Masala Dosa |
Sourav | Biryani |
Rohan | Chole Batura |
Rumman | Birayani |
Live Preview
Example: 5 <table frame="lhs">
A border on the left side of table.
Name | Food |
---|---|
Jakir | Rasgola |
Sabir | Masala Dosa |
Sourav | Biryani |
Rohan | Chole Batura |
Rumman | Birayani |
Live Preview
Example: 6 <table frame="rhs">
A border on the right side of table.
Name | Food |
---|---|
Jakir | Rasgola |
Sabir | Masala Dosa |
Sourav | Biryani |
Rohan | Chole Batura |
Rumman | Birayani |
Live Preview
Example: 7 <table frame="vsides">
A border on the left and right sides of table.
Name | Food |
---|---|
Jakir | Rasgola |
Sabir | Masala Dosa |
Sourav | Biryani |
Rohan | Chole Batura |
Rumman | Birayani |
Live Preview
Example: 8 <table frame="box">
A border on all side
Name | Food |
---|---|
Jakir | Rasgola |
Sabir | Masala Dosa |
Sourav | Biryani |
Rohan | Chole Batura |
Rumman | Birayani |
Live Preview
Example: 9 <table frame="border">
A border on all sides
Name | Food |
---|---|
Jakir | Rasgola |
Sabir | Masala Dosa |
Sourav | Biryani |
Rohan | Chole Batura |
Rumman | Birayani |
Live Preview
Example:
Another example with mix of different attribute
Name | Food |
---|---|
Jakir | Rasgola |
Sabir | Masala Dosa |
Sourav | Biryani |
Rohan | Chole Batura |
Rumman | Birayani |