20. Write a code to change the color of the background or text? Explain the
elements involved in it.
To change the color of the background of the body or the text there is a
<body> tag that has to be included where there are some elements that has
to be used to set the properties of it. The code is as follows:
<html>
<head>
</head>
<BODY BGCOLOR="#ffffff" TEXT="#000000" LINK="#000000" VLINK="#000000"
ALINK="#ffff00">
</body>
</html>
The elements that are used in this tag is as follows:
BGCOLOR: represents the background color which will be applied totally on the
body if there is no other bgcolor used with any other tag internally.
TEXT: represents the color of the text that will be applied to the complete
text present in the body.
LINK: represents the color of all the text links that are present inside the
body.
VLINK: represents the color of the links that has already been visited.
ALINK: represents the color of the text links that will change when the page
accessed will be active.
21. What is the main function of <pre> tag in HTML?
<pre> tag defines the pre-formatted text that is used to display the text
with the fixed width and uses a predefined fonts and it keeps both spaces and
line breaks separate and show the text as it is. The code that can be used to
display the text that can be written in whatever way the user wants is as
follows:
<pre>
Text in a pre element ----//
is displayed in a fixed-width
font, and it preserves
both spaces and
line breaks
</pre>
22. How can tables be made nested in HTML?
Tables can be made nested by making it come in another table. This consists of
many attributes and tags that can be used in nesting the tables. The tags that
are used for the table is as follows:
<TR>: This is the tag that has to be written after the <table> tag
and before any other tags. This makes a table row that store the data elements.
<TD>: This tag can be used anywhere and it consists of the data that has
to come on the website.
<TH>: This tag consists of the table heading.
The sample code will explain the above explanation much better:
<table>
<tr>
<td>this is the first cell</td>
<td>this is the second cell
<table> <!--Starting of the table that is embedded inside another
table-->
<tr>
<td>this is the first cell second table</td>
<td>this is the second cell of second table</td>
</tr>
</table>
</td>
</tr>
</table>
23. How can tables be used inside a form? Explain with an example.
A form can consist of the table and its properties to display it on the web
page. The form is placed with the <td> tag that includes the data of the
table. This can also be used to position the form in relation to the other
content. The table will be added within the form. The code is given as:
<FORM ACTION="[URL]">
<TABLE>
<TR>
<TH>This is the table heading</TH>
<TD><INPUT TYPE="text" NAME="account"></TD>
</TR>
<TR>
<TH>This is another heading for a button</TH>
<TD><INPUT TYPE="password" NAME="password"></TD>
</TR>
<TR>
<TD> </TD>
<TD><INPUT TYPE="submit" NAME="Log On"></TD>
</TR>
</TABLE>
</FORM>
In this the form elements are getting used inside the table tags like <input
type>, <text area>, etc. The form input will be given using the
<td> tag that displays the table data and related information
accordingly.
24. What are the different ways to use different colors for different links or
same link?
The presentation is being done by CSS that is used with the HTML, to give the
style to the HTML content. This is called as style sheet. The links can be
specified in different colors by the following way:
a:link {color: blue; background: white}
a:visited {color: purple; background: white}
a:active {color: red; background: white}
This is the CSS properties that is being defined to set the color for the links
that are active, visited and normal link. User can use the class attribute in
the tags like <a> to use it and see the change in the link color. It is
shown as:
<a class="exp" href="[URL]">example of the link</a>
The style sheet can be modified according to the code that is being written.
The coding will include:
a.exp:link {color: yellow; background: black}
a.exp:visited {color: white; background: black}
a.exp:active {color: red; background: black}
|