In HTML, the <table>
tag is used to create tables to display data in a structured grid format. The <table>
tag can contain several attributes that help in defining and customizing the behavior and appearance of the table. Here are some commonly used attributes of the <table>
tag:
1. border:
border
attribute is used to set the border width around the table and its cells.<table border="1">
2. cellpadding:
<table cellpadding="5">
3. cellspacing:
cellspacing
attribute specifies the space between table cells.<table cellspacing="5">
4. width:
<table width="100%">
5. height:
height
attribute sets the height of the table.<table height="200">
6. align:
align
attribute aligns the table with respect to the surrounding content (left, center, right).<table align="center">
7. summary:
summary
attribute provides a brief description of the table's content for accessibility purposes.<table summary="Monthly sales data">
8. bordercolor:
bordercolor
attribute sets the color of the table border.<table bordercolor="#CCCCCC">
9. bgcolor:
bgcolor
attribute sets the background color of the table.<table bgcolor="#F5F5F5">
Please note that while these attributes can be used for basic formatting, it's generally recommended to use CSS (Cascading Style Sheets) for styling HTML elements, including tables. CSS provides more control and flexibility for formatting and styling tables, and it separates the design from the content, making it easier to maintain and customize the appearance of the table.