• +91 9971497814
  • info@interviewmaterial.com

HTML Interview Questions Answers

Question 1 : How do I align a table to the right (or left)?

Answer 1 : You can use <TABLE ALIGN="right"> to float a table to the right. (Use ALIGN="left" to float it to the left.) Any content that follows the closing </TABLE> tag will flow around the table. Use <BR CLEAR="right"> or <BR CLEAR="all"> to mark the end of the text that is to flow around the table, as shown in this example: The table in this example will float to the right. <table align="right">...</table> This text will wrap to fill the available space to the left of (and if the text is long enough, below) the table. <br clear="right"> This text will appear below the table, even if there is additional room to its left.

Question 2 : Can I nest tables within tables?

Answer 2 : Yes, a table can be embedded inside a cell in another table. Here's a simple example: <table> <tr> <td>this is the first cell of the outer table</td> <td>this is the second cell of the outer table, with the inner table embedded in it <table> <tr> <td>this is the first cell of the inner table</td> <td>this is the second cell of the inner table</td> </tr> </table> </td> </tr> </table> The main caveat about nested tables is that older versions of Netscape Navigator have problems with them if you don't explicitly close your TR, TD, and TH elements. To avoid problems, include every </tr>, </td>, and </th> tag, even though the HTML specifications don't require them. Also, older versions of Netscape Navigator have problems with tables that are nested extremely deeply (e.g., tables nested ten deep). To avoid problems, avoid nesting tables more than a few deep. You may be able to use the ROWSPAN and COLSPAN attributes to minimize table nesting. Finally, be especially sure to validate your markup whenever you use nested tables.  

Question 3 : How comfortable are you with writing HTML entirely by hand?

Answer 3 : Very. I don’t usually use WYSIWYG. The only occasions when I do use Dreamweaver are when I want to draw something to see what it looks like, and then I’ll usually either take that design and hand-modify it or build it all over again from scratch in code. I have actually written my own desktop HTML IDE for Windows (it’s called Less Than Slash) with the intention of deploying it for use in web development training. If has built-in reference features, and will autocomplete code by parsing the DTD you specify in the file. That is to say, the program doesn’t know anything about HTML until after it parses the HTML DTD you specified. This should give you some idea of my skill level with HTML.

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

Answer 4 : 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 5 : How do I create a link that sends me email?

Answer 5 : 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 6 : How can I make a form with custom buttons?

Answer 6 : 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 7 : Can I use percentage values for <TD WIDTH=...>?

Answer 7 : 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 8 : How do I get form data emailed to me?

Answer 8 : The only reliable mechanism for processing form submissions is with a server-side (e.g., CGI) program. To send form data to yourself via email, you should use a server-side program that processes the form submission and sends the data to your email address. Some web service providers make standard form-to-email programs available to their customers. Check with your service provider for details. If you can install CGI programs on your own server, see the answer to the previous question for a list of useful resources. If you can't run CGI programs on your own server, you can use a remotely hosted form-to-email services. Note that the provider of a remotely hosted service will have access to any data submitted via the service. Forms that use action="mailto:..." are unreliable. According to the HTML specifications, form behavior is explicitly undefined for mailto URIs (or anything else other than HTTP URIs). They may work one way with one software configuration, may work other ways in other software configurations, and may fail completely in other software configurations.

Question 9 : Can I prevent a form from being submitted again?

Answer 9 : No. The server-side (e.g., CGI) program that processes the form submission must handle duplicate submissions gracefully. You could generate the form with a server-side (e.g., CGI) program that adds a hidden field with a unique session ID. Then the server-side program that processes the form submission can check the session ID against a list of previously used session IDs. If the session ID has already been used, then an appropriate action can be taken (e.g., reject the submission, or update the previously submitted data). Ultimately, your server-side program must be smart enough to handle resubmitted data. But you can avoid getting resubmitted data by not expiring the confirmation page from form submissions. Since you want to expire pages quickly when they have transient data, you might want to avoid putting transient data on the confirmation page. You could provide a link to a database query that returns transient data though.

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

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

HTML Contributors

krishan

Share your email for latest updates

Name:
Email:

Our partners