February 15, 2019

Srikaanth

Mphasis Frequently Asked HTML Interview Questions Answers

How Can I Specify Colors?

If you want others to view your web page with specific colors, the most appropriate way is to suggest the colors with a style sheet. Cascading Style Sheets use the color and background-color properties to specify text and background colors. To avoid conflicts between the reader's default colors and those suggested by the author, these two properties should always be used together.

With HTML, you can suggest colors with the TEXT, LINK, VLINK (visited link), ALINK (active link), and BGCOLOR (background color) attributes of the BODY element.

Note that these attributes are deprecated by HTML 4. Also, if one of these attributes is used, then all of them should be used to ensure that the reader's default colors do not interfere with those suggested by the author. Here is an example

<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#000080">
Authors should not rely on the specified colors since browsers allow their users to override document-specified colors.

How Can I Allow File Uploads To My Web Site?

These things are necessary for Web-based uploads

* An HTTP server that accepts uploads.
* Access to the /cgi-bin/ to put the receiving script. Prewritten CGI file-upload scripts are available.
* A form implemented something like this

<form method="post" enctype="multipart/form-data" action="fup.cgi">
File to upload: <input type=file name=upfile><br>
Notes about the file: <input type=text name=note><br>
<input type=submit value=Press> to upload the file!
</form>

Not all browsers support form-based file upload, so try to give alternatives where possible.
The Perl CGI.pm module supports file upload. The most recent versions of the cgi-lib.pl library also support file upload. Also, if you need to do file upload in conjunction with form-to-email, the Perl package MIME::Lite handles email attachments.

How Can I Require That Fields Be Filled In, Or Filled In Correctly?

Have the server-side (e.g., CGI) program that processes the form submission send an error message if the field is not filled in properly. Ideally, this error message should include a copy of the original form with the original (incomplete or incorrect) data filled in as the default values for the form fields. The Perl CGI.pm module provides helpful mechanisms for returning partially completed forms to the user.

In addition, you could use JavaScript in the form's ONSUBMIT attribute to check the form data. If JavaScript support is enabled, then the ONSUBMIT event handler can inform the user of the problem and return false to prevent the form from being submitted.
Mphasis Frequently Asked HTML Interview Questions Answers
Mphasis Frequently Asked HTML Interview Questions Answers

How Can I Check For Errors?

HTML validators check HTML documents against a formal definition of HTML syntax and then output a list of errors. Validation is important to give the best chance of correctness on unknown browsers (both existing browsers that you haven't seen and future browsers that haven't been written yet).

HTML checkers (linters) are also useful. These programs check documents for specific problems, including some caused by invalid markup and others caused by common browser bugs. Checkers may pass some invalid documents, and they may fail some valid ones.

All validators are functionally equivalent; while their reporting styles may vary, they will find the same errors given identical input. Different checkers are programmed to look for different problems, so their reports will vary significantly from each other. Also, some programs that are called validators (e.g. the "CSE HTML Validator") are really linters/checkers. They are still useful, but they should not be confused with real HTML validators.

When checking a site for errors for the first time, it is often useful to identify common problems that occur repeatedly in your markup. Fix these problems everywhere they occur (with an automated process if possible), and then go back to identify and fix the remaining problems.

Link checkers follow all the links on a site and report which ones are no longer functioning. CSS checkers report problems with CSS style sheets.

Do I Have To Memorize A Bunch Of Tags?

No. Most programs that help you write HTML code already know most tags, and create them when you press a button. But you should understand what a tag is, and how it works. That way you can correct errors in your page more easily.

How Do I Make A Form So It Can Be Submitted By Hitting Enter?

The short is that the form should just have one <INPUT TYPE=TEXT> and no TEXTAREA, though it can have other form elements like checkboxes and radio buttons.

How Do I Set The Focus To The First Form Field?

You cannot do this with HTML. However, you can include a script after the form that sets the focus to the appropriate field, like this

<form id="myform" name="myform" action=...>
<input type="text" id="myinput" name="myinput" ...>
</form>

<script type="text/javascript">
document.myform.myinput.focus();
</script>

A similar approach uses <body onload=...> to set the focus, but some browsers seem to process the ONLOAD event before the entire document (i.e., the part with the form) has been loaded.

How Can I Eliminate The Extra Space After A Tag?

HTML has no mechanism to control this. However, with CSS, you can set the margin-bottom of the form to 0. For example
<form style="margin-bottom:0;" action=...>

You can also use a CSS style sheet to affect all the forms on a page
form { margin-bottom: 0 ; }

How Can I Show Html Examples Without Them Being Interpreted As Part Of My Document?

Within the HTML example, first replace the "&" character with "&amp;" everywhere it occurs. Then replace the "&lt;" character with "<" and the "&gt;" character with ">" in the same way.

Note that it may be appropriate to use the CODE and/or PRE elements when displaying HTML examples.

How Do I Eliminate The Blue Border Around Linked Images?

In your HTML, you can specify the BORDER attribute for the image
<a href=...><img src=... alt=... border="0"></a>
However, note that removing the border that indicates an image is a link makes it harder for users to distinguish quickly and easily which images on a web page are clickable.

How Do I Change The Title Of A Framed Document?

The title displayed is the title of the frameset document rather than the titles of any of the pages within frames. To change the title displayed, link to a new frameset document using TARGET="_top" (replacing the entire frameset).

How Can I Make A Form With Custom Buttons?

Rather than a normal submit button (<input type="submit" ...>), you can use the image input type (<input type="image" ...>). The image input type specifies a graphical submit button that functions like a server-side image map.

Unlike normal submit buttons (which return a name=value pair), the image input type returns the x-y coordinates of the location where the user clicked on the image. The browser returns the x-y coordinates as name.x=000 and name.y=000 pairs.

ronments, the VALUE and ALT attributes should be set to the same value as the NAME attribute. For example

<input type="image" name="Send" alt="Send" value="Send" src="send-button.gif">
For the reset button, one could use <button type="reset" ...>, JavaScript, and/or style sheets, although none of these mechanisms work universally.

Subscribe to get more Posts :