• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

HTML Interview Questions Answers

Question - 1 : - Why doesn't <TABLE WIDTH="100%"> use the full browser width?

Answer - 1 : - 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.

Question - 2 : - How do I keep people from stealing my source code and/or images?

Answer - 2 : - Because copies of your HTML files and images are stored in cache, it is impossible to prevent someone from being able to save them onto their hard drive. If you are concerned about your images, you may wish to embed a watermark with your information into the image. Consult your image editing program's help file for more details. The colors on my page look different when viewed on a Mac and a PC. The Mac and the PC use slightly different color palettes. There is a 216 "browser safe" color palette that both platforms support; the Microsoft color picker page has some good information and links to other resources about this. In addition, the two platforms use different gamma (brightness) values, so a graphic that looks fine on the Mac may look too dark on the PC. The only way to address this problem is to tweak the brightness of your image so that it looks acceptable on both platforms.

Question - 3 : - How do I set the focus to the first form field?

Answer - 3 : - 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.

Question - 4 : - Are there any problems with using frames?

Answer - 4 : - The fundamental problem with the design of frames is that framesets create states in the browser that are not addressable. Once any of the frames within a frameset changes from its default content, there is no longer a way to address the current state of the frameset. It is difficult to bookmark - and impossible to link or index - such a frameset state. It is impossible to reference such a frameset state in other media. When the sub-documents of such a frameset state are accessed directly, they appear without the context of the surrounding frameset. Basic browser functions (e.g., printing, moving forwards/backwards in the browser's history) behave differently with framesets. Also, browsers cannot identify which frame should have focus, which affects scrolling, searching, and the use of keyboard shortcuts in general. Furthermore, frames focus on layout rather than on information structure, and many authors of framed sites neglect to provide useful alternative content in the NOFRAMES element. Both of these factors cause accessibility problems for browsers that differ significantly from the author's expectations and for search engines.

Question - 5 : - Can I have two or more Submit buttons in the same form?

Answer - 5 : - Yes. This is part of HTML 2.0 Forms support (some early browsers did not support it, but browser coverage is now excellent). The submit buttons must have a NAME attribute. The optional VALUE attribute can be used to specify different text for the different submit buttons. To determine which submit button was used, you need to use different values for the NAME and/or VALUE attributes. Browsers will send to the server the name=value pair of the submit button that was used. Here is an example: <input type="submit" name="join" value="I want to join now"> <input type="submit" name="info" value="Please send full details"> Note that if you are using image submit buttons, you need to provide different NAME attributes for them too. Also, browser behavior can be inconsistent when the form is submitted without a submit button (e.g., by hitting ENTER). If you're unsure what results you're going to get when you submit your form, TipJar has a standard script which you can use. Code this, for example (assuming method "post"): <form method="post" action="http://www.yoursite.com/cgi-bin/test"> and then go through the motions of submitting your form. The TipJar server decodes the form input, and displays the result to you.

Question - 6 : - How can I allow file uploads to my web site?

Answer - 6 : - 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.

Question - 7 : - How can I show HTML examples without them being interpreted as part of my document?

Answer - 7 : - 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.

Question - 8 : - Can I use percentage values for <TD WIDTH=...>?

Answer - 8 : - 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.

Question - 9 : - How can I make a form with custom buttons?

Answer - 9 : - 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. For compatability with various non-graphical browsing environments, 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.

Question - 10 : - How can I require that fields be filled in, or filled in correctly?

Answer - 10 : - 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. Note that the server-side program should not rely upon the checking done by the client-side script.

Computer Contributors

krishan
Rajeev Katiyar
Yes Baroda

Share your email for latest updates

Name:
Email:

Our partners