HTML | Tags and Attributes [TABLE] [Formatting] [Background color and images]




Ü Including background color and images : To include background color, we will need to add the attribute BGCOLOR in the <TABLE> tag as follows,
            <TABLE BGCOLOR=”……”>
The value of the BGCOLOR attribute will be the background color of the table. But we can use that BGCOLOR attribute in the <TH> and <TD> tag also. Doing so, each cell can be colored differently
.
Input:
<HTML><HEAD><TITLE>TABLE</TITLE></HEAD>
<BODY>
Use of background color for the whole table..<BR>
<TABLE BORDER=1 WIDTH=50% BGCOLOR=YELLOW>
<CAPTION><B><U><FONT SIZE=5>AMERICA</FONT></B></U></CAPTION>
<TR>
<TD ALIGN=CENTER COLSPAN=2>USA</TD>
</TR>
<TR>
<TD ALIGN=CENTER>New York</TD>
<TD ALIGN=CENTER>New Jersy</TD>
</TR>
</TABLE>
<BR>Use of different background color for cells..<BR>
<TABLE BORDER=1 WIDTH=50%>
<CAPTION><B><U><FONT SIZE=5>AMERICA</FONT></B></U></CAPTION>
<TR>
<TD BGCOLOR=YELLOW ALIGN=CENTER COLSPAN=2>USA</TD>
</TR>
<TR>
<TD BGCOLOR=RED ALIGN=CENTER>New York</TD>
<TD BGCOLOR=GREEN ALIGN=CENTER>New Jersy</TD>
</TR>
</TABLE></BODY></HTML>
Output: 















Recommended Recommends

Comments

Contact Us