• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

HTML Interview Questions Answers

Question - 31 : - Should I end my URLs with a slash?

Answer - 31 : - The URL structure defines a hierarchy similar to a filesystem's hierarchy of subdirectories or folders. 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. When resolving relative URLs (see the answer to the previous question), the browser's first step is to strip everything after the last slash in the URL of the current document. If the current document's URL ends with a slash, then the final segment (the "file") of the URL is null. If you remove the final slash, then the final segment of the URL is no longer null; it is whatever follows the final remaining slash in the URL. Removing the slash changes the URL; the modified URL refers to a different document and relative URLs will resolve differently. For example, the final segment of the URL http://www.mysite.com/faq/html/ is empty; there is nothing after the final slash. In this document, the relative URL all.html resolves to http://www.mysite.com/faq/html/all.html (an existing document). If the final slash is omitted, then the final segment of the modified URL http://www.mysite.com/faq/html is "html". In this (nonexistent) document, the relative URL all.html would resolve to http://www.mysite.com/faq/all.html (another nonexistent document). When they receive a request that is missing its final slash, web servers cannot ignore the missing slash and just send the document anyway. Doing so would break any relative URLs in the document. Normally, servers are configured to send a redirection message when they receive such a request. In response to the redirection message, the browser requests the correct URL, and then the server sends the requested document. (By the way, the browser does not and cannot correct the URL on its own; only the server can determine whether the URL is missing its final slash.) This error-correction process means that URLs without their final slash will still work. However, this process wastes time and network resources. If you include the final slash when it is appropriate, then browsers won't need to send a second request to the server. The exception is when you refer to a URL with just a hostname (e.g., http://www.mysite.com). In this case, the brows

Question - 32 : - What is the difference between the HTML form methods GET and POST?

Answer - 32 : - The method parameter specifies which method the client is using to send information to the WEB server. The method determines which parameter you will find the CGI request data in: * POST - post_args * GET - httpargs

Question - 33 : - How do I make a link or form in one frame update another frame?

Answer - 33 : - In the frameset document (the HTML document containing the <frameset> <frame> tags), make sure to name the individual frames using the NAME attribute. The following example creates a top frame named "navigation" and a bottom frame named "content": <frameset rows="*,3*"> <frame name="navigation" src="navigation.html"> <frame name="content" src="content.html"> <noframes><body> <!-- Alternative non-framed version --> </body></noframes> </frameset> Then, in the document with the link, use the TARGET attribute to specify which frame should be used to display the link. (The value of the TARGET attribute should match the value of the target frame's NAME attribute.) For example: <a target="content" href=...> To target a form submission, use the TARGET attribute of the FORM element, like this: <form target="content" action=...> Note that when forms are processed entirely by JavaScript, the target frame must be specified in the JavaScript. The value of the TARGET attribute is irrelevant. Normally, the default target frame is the current frame ("_self"). To change the default target for every link/form on the page, use the TARGET attribute of the BASE element, like this:

Question - 34 : - How can I include comments in HTML?

Answer - 34 : - Technically, since HTML is an SGML application, HTML uses SGML comment syntax. However, the full syntax is complex, and browsers don't support it in its entirety anyway. Therefore, use the following simplified rule to create HTML comments that both have valid syntax and work in browsers: An HTML comment begins with "<!--", ends with "-->", and does not contain "--" or ">" anywhere in the comment. The following are examples of HTML comments: * <!-- This is a comment. --> * <!-- This is another comment, and it continues onto a second line. --> * <!----> Do not put comments inside tags (i.e., between "<" and ">") in HTML markup.

Question - 35 : - How can I have two sets of links with different colors?

Answer - 35 : - 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}

Question - 36 : - How can I check for errors?

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

Question - 37 : - How can I specify background images?

Answer - 37 : - With HTML, you can suggest a background image with the BACKGROUND attribute of the BODY element. Here is an example: <body background="imagefile.gif" bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#000080"> If you specify a background image, you should also specify text, link, and background colors since the reader's default colors may not provide adequate contrast against your background image. The background color may be used by those not using your background image. Authors should not rely on the specified background image since browsers allow their users to disable image loading or to override document-specified backgrounds.

Question - 38 : - How do I create a button which acts like a link?

Answer - 38 : - This is best done with a small form: <FORM ACTION="[URL]" METHOD=GET> <INPUT TYPE=submit VALUE="Text on button"> </FORM> If you want to line up buttons next to each other, you will have to put them in a one-row table, with each button in a separate cell. Note that search engines might not find the target document unless there is a normal link somewhere else on the page. A go-to-other-page button can also be coded in JavaScript, but the above is standard HTML and works for more readers.

Question - 39 : - How do I create a link that sends me email?

Answer - 39 : - Some examples, with actual HTML Code included, follow: Simple MailTo <a href="mailto:info@exammaterial.com"> MailTo with Multiple Recipients <a href="mailto:info@exammaterial.com,info@exammaterial.com"> MailTo with Subject <a href="mailto:info@exammaterial.com?subject=Comments from MailTo Syntax Page"> MailTo with a Copy <a href="mailto:info@exammaterial.com?cc=support@exammaterial.com"> MailTo with a Blind Copy <a href="mailto:info@exammaterial.com?bcc=support@exammaterial.com"> MailTo with message already started in Body <a href="mailto:info@exammaterial.com?body=I am having trouble finding information on "> MailTo with multiline message in Body <a href="mailto:info@exammaterial.com?body=The message's first paragraph.%0A%0aSecond paragraph.%0A%0AThird Paragraph."> NOTE: Use "%0A" for a new line, use "%0A%0A" for a new line preceded by a blank line. Features may be used in combination MailTo with Subject, a Recipient, a Copy and a Blind Copy <a href="mailto:info@exammaterial.com?subject=MailTo Comments&cc=ASTARK1@UNL.EDU&bcc=id@internet.node"> Remember to use only one ? (question mark), when providing multiple entries beyond e-mail address

Question - 40 : - How do I let people download a file from my page?

Answer - 40 : - Once the file is uploaded to the server, you need only use an anchor reference tag to link to it. An example would be: <a href="../files/foo.zip">Download Foo Now! (100kb ZIP)</a>

Computer Contributors

Rajeev Katiyar
Yes Baroda

Share your email for latest updates


Our partners