News:

Build a stunning handcrafted website with IT Acumens

Main Menu

HTML Interview Questions And Answers _ 2

Started by ganeshbala, Mar 28, 2008, 03:36 PM

Previous topic - Next topic

ganeshbala

HTML Interview Questions And Answers

Can I have two or more actions in the same form?
No. A form must have exactly one action. However, the server-side (e.g., CGI) program that processes your form submissions can perform any number of tasks (e.g., updating a database, sending email, logging a transaction) in response to a single form submission.

How can I use forms for pull-down navigation menus?
There is no way to do this in HTML only; something else must process the form. JavaScript processing will work only for readers with JavaScript-enabled browsers. CGI and other server-side processing is reliable for human readers, but search engines have problems following any form-based navigation.

How can I avoid using the whole URL?
The URL structure defines a hierarchy (or relationship) that is similar to the hierarchy of subdirectories (or folders) in the filesystems used by most computer operating systems. The segments of a URL are separated by slash characters ("/"). When navigating the URL hierarchy, the final segment of the URL (i.e., everything after the final slash) is similar to a file in a filesystem. The other segments of the URL are similar to the subdirectories and folders in a filesystem.
A relative URL omits some of the information needed to locate the referenced document. The omitted information is assumed to be the same as for the base document that contains the relative URL. This reduces the length of the URLs needed to refer to related documents, and allows document trees to be accessed via multiple access schemes (e.g., "file", "http", and "ftp") or to be moved without changing any of the embedded URLs in those documents.
Before the browser can use a relative URL, it must resolve the relative URL to produce an absolute URL. If the relative URL begins with a double slash (e.g., //www.yoursite.com/faq/html/), then it will inherit only the base URL's scheme. If the relative URL begins with a single slash (e.g., /faq/html/), then it will inherit the base URL's scheme and network location.
If the relative URL does not begin with a slash (e.g., all.html , ./all.html or ../html/), then it has a relative path and is resolved as follows.

1. The browser strips everything after the last slash in the base document's URL and appends the relative URL to the result.
2. Each "." segment is deleted (e.g., ./all.html is the same as all.html, and ./ refers to the current "directory" level in the URL hierarchy).
3. Each ".." segment moves up one level in the URL hierarchy; the ".." segment is removed, along with the segment that precedes it (e.g., foo/../all.html is the same as all.html, and ../ refers to the parent "directory" level in the URL hierarchy).

Some examples may help make this clear. If the base document is <URL:http://www.yoursite.com/faq/html/basics.html>, then

all.html and ./all.html
refer to <URL:http://www.yoursite.com/faq/html/all.html>
./
refers to <URL:http://www.yoursite.com/faq/html/>
../
refers to <URL:http://www.yoursite.com/faq/>
../cgifaq.html
refers to <URL:http://www.yoursite.com/faq/cgifaq.html>
../../reference/
refers to <URL:http://www.yoursite.com/reference/>

Please note that the browser resolves relative URLs, not the server. The server sees only the resulting absolute URL. Also, relative URLs navigate the URL hierarchy. The relationship (if any) between the URL hierarchy and the server's filesystem hierarchy is irrelevant.

Can I use percentage values for <TD WIDTH=...>?
The HTML 3.2 and HTML 4.0 specifications allow only integer values (representing a number of pixels) for the WIDTH attribute of the TD element. However, the HTML 4.0 DTD allows percentage (and other non-integer) values, so an HTML validator will not complain about <TD WIDTH="xx%">.
It should be noted that Netscape and Microsoft's browsers interpret percentage values for <TD WIDTH=...> differently. However, their interpretations (and those of other table-aware browsers) happen to match when combined with <TABLE WIDTH="100%">. In such situations, percentage values can be used relatively safely, even though they are prohibited by the public specifications.

Why doesn't <TABLE WIDTH="100%"> use the full browser width?
Graphical browsers leave a narrow margin between the edge of the display area and the content.
Also note that Navigator always leaves room for a scrollbar on the right, but draws the scrollbar only when the document is long enough to require scrolling. If the document does not require scrolling, then this leaves a right "margin" that cannot be removed.

Why is there extra space before or after my table?
This is often caused by invalid HTML syntax. Specifically, it is often caused by loose content within the table (i.e., content that is not inside a TD or TH element). There is no standard way to handle loose content within a table. Some browsers display all loose content before or after the table. When the loose content contains only multiple line breaks or empty paragraphs, then these browsers will display all this empty space before or after the table itself.
The solution is to fix the HTML syntax errors. All content within a table must be within a TD or TH element.

How do I create a link that sends me email?
Use a mailto link, for example

How can I have two sets of links with different colors?
You can suggest this presentation in a style sheet. First, specify colors for normal links, like this:

a:link {color: blue; background: white}
a:visited {color: purple; background: white}
a:active {color: red; background: white}

Next, identify the links that you want to have different colors. You can use the CLASS attribute in your HTML, like this:

<a class="example1" href="[URL]">[link text]</a>
Then, in your style sheet, use a selector for links with this CLASS attribute, like this:

a.example1:link {color: yellow; background: black}
a.example1:visited {color: white; background: black}
a.example1:active {color: red; background: black}

Alternatively, you can identify an element that contains the links that you want to have different colors, like this:

<div class="example2">...
<a href="[URL]">[link text]</a>...
<a href="[URL]">[link text]</a>...
<a href="[URL]">[link text]</a>...
</div>

Then, in your style sheet, use a selector for links in this containing element, like this:

.example2 a:link {color: yellow; background: black}
.example2 a:visited {color: white; background: black}
.example2 a:active {color: red; background: black}