200+ Important Question Answer
Unit 2 – HTML II [Tables in HTML]
Question and Answers
1. What is the use of Table in HTML?
Answer: A table in HTML helps to arrange data into rows and columns of cells. It is useful to display tabular data.
2. Which tag of HTML is used to create a Table in HTML?
Answer: Following tags are used in HTML to create tables in HTML. These are <TABLE>, <TBODY>, <THEAD>, <TFOOT>, <TR>, <TH>, <TD> and <CAPTION>
3. What is the <TABLE> tag in HTML?
Answer: <TABLE> tag in HTML is use to create tables in HTML. It is a container tag, which contains all table elements. It is having an ending tag </TABLE>.
4. What is the <TR> tag in HTML?
Answer: <TR> tag in HTML is use to define a table row. It is a container tag, which contains table data or table header cells. It is having an ending tag </TR>
5. What is the <TD> tag in HTML?
Answer: <TD> tag in HTML is use to define a table data. It is a container tag, which contains table data cells. It is having an ending tag </TD>
6. What is the <TH> tag in HTML?
Answer: <TH> tag in HTML is used to define a table header. It is a container tag, which defines table header cells. It is having an ending tag </TH>
7. What is the <CAPTION> tag in HTML?
Answer: <CAPTION> tag defines the title or caption of a table. It provides a short description of the table.
8. Write the name of all attributes of <TABLE> tag in HTML?
Answer: <TABLE> tag has the following attributes. BORDER, BORDERCOLOR, FRAME, RULES, CELLPADDING, CELLSPACING, BACKGROUND, BGCOLOR, HEIGHT, WIDHT, ALIGN
9. Write the code in HTML to create a table having 3 rows and 2 – columns?
Answer: An HTML code for a Table having 3 rows and 2 columns.
<!DOCTYPE html>
<HTML>
<HEAD>
<TITLE> Creating Table in HTML </TITLE>
</HEAD>
<BODY>
<TABLE>
<TR>
<TD> 1 </TD> <TD> 2 </TD> <TD> 3 </TD>
</TR>
<TR>
<TD> 4 </TD> <TD> 5 </TD> <TD> 6 </TD>
</TR>
</TABLE>
</BODY>
</HTML>
10. What is the BORDER attribute of the TABLE tag?
Answer: The BORDER attribute of <TABLE> tag, specify the border of the table. It tells the table how large the border should be. The value of the BORDER attribute is given in pixels.
<TABLE BORDER = 1> … </TABLE> <TABLE BORDER = 4> … </TABLE>
11. What is the BORDERCOLOR attribute of the TABLE tag?
Answer: The BORDERCOLOR attribute of the <TABLE> tag, specify the color of the border of the table. By default color of the border of the table is BLACK. The BORDERCOLOR attribute is used only with the BORDER attribute.
<TABLE BORDER = 1 BORDERCOLOR=”RED”> … </TABLE> <TABLE BORDER = 4 BORDERCOLOR = “#056989”> … </TABLE>
12. Write HTML code, to show the uses of BORDER and BORDERCOLOR attribute of TABLE tag.
Answer: Code for BORDER and BORDERCOLOR
<!DOCTTYPE html>
<HTML>
<HEAD>
<TITLE> Creating Table in HTML </TITLE>
</HEAD>
<BODY>
<TABLE BORDER="2" BORDERCOLOR="RED">
<TR>
<TD> 1 </TD> <TD> 2 </TD> <TD> 3 </TD>
</TR>
<TR>
<TD> 4 </TD> <TD> 5 </TD> <TD> 6 </TD>
</TR>
</TABLE>
</BODY>
</HTML>
13. What is the FRAME attribute of the TABLE tag.
Answer: The FRAME attribute of the <TABLE> tag allows to specify which portion (i.e. part or side) of the border will display. It is used along with the BORDER attribute.
Values of the FRAME attribute are:-
above | display top edge only. |
below | display bottom edge only. |
border | display all four sides. |
box | display all four sides. |
hsides | display top and bottom edges. |
lhs | display left edge only. |
rhs | display right edge only. |
void | display no border |
vsides | displays left and right edges. |
14. Write the HTML code to show the use of the FRAME attribute.
Answer: Code for showing how to use the FRAME attribute is
<!DOCTTYPE html>
<HTML>
<HEAD>
<TITLE> Creating Table in HTML using FRAME attribute </TITLE>
</HEAD>
<BODY>
<p>FRAME = "above"</p>
<TABLE BORDER="1" BORDERCOLOR="black" FRAME = "above">
<TR>
<TD> C-1</TD> <TD> C-2 </TD> <TD> C-3 </TD>
</TR>
<TR>
<TD> A </TD> <TD> B </TD> <TD> C</TD>
</TR>
</TABLE>
</BODY>
</HTML>
15. What is the RULES attribute of the TABLE tag.
Answer: The RULES attribute of the <TABLE> tag allows to specify which portion of the inside border edge will display. It is used along with the BORDER attribute.
Values of the RULES attribute are-
all | displays all borders. |
cols | displays borders between cells. |
groups | displays borders between all cell groups. |
none | hides all interior borders. |
rows | display borders between rows only. |