Sunday, 1 September 2013

40 - HTML Interview Questions

      1. What is HTML?
Ans. HTML stands for "Hyper Text Markup Language".HTML document contains markup tags that provides a  way of displaying text, images, and multimedia content.HTML file must have an htm or html file extension.

      2. In which year HTML was first proposed?
Ans.  In 1980

3. Who is the author of HTML?
Ans. Sir Tim Berners-Lee

     4. What is the structure of HTML?
Ans.   <html> tag start
                <head> tag start
                <title> tag start
                </title> tag close
                </head> tag close
                <body> tag start
                  tag internal tags
               </body> tag close
               </html> tag close

    5. Is it necessary for HTML document to have an end/close tag?
Ans. No. if we don’t close the tag then the output will be the same. 
      
     6. Does the HTML table contain nested tables?
 Ans. Yes.

     7. How to set the position of the table at the center of the webpage?
Ans. We can do it by using following two methods:
               Using align="center" attribute
               Using <center> tag

      8. Describe Common Lists?
Ans. ordered list
               unordered list
               definition list
               menu list
               directory list
      9. How do you insert a comment in HTML?
Ans. <!-- comment will be here! -->

10.   What is the purpose of using a marquee tag?
      Ans. If we want to scroll text/images in a webpage then marquee tag is used to do the                        same.
              For Example:
              <html>
              <head>
<title>This is the marquee tag example </title>
             </head>
<body>
<marquee> marquee element is used for scrolling text </marquee>
</body>
           </html>

       11. What is <br> tag?
 Ans. <br> tag places break rows between tags.
              For Example:
             <html>
            <head>
     <title>This is the br  tag example </title>
            </head>
            <body>
Hello readers<br> This is the breaking row tag.
            </body>
           </html>

       12. How to set the background image of the webpage?
 Ans. <body background="url of image">
              For Example:
              <html>
             <head>
           <title>This is the background image  tag example </title>
             </head>
             <body background="../img.png">
Hello readers<br> This is the breaking row tag.
             </body>
             </html>

      13. What is the file extension of HTML?
Ans. .htm or .html

      14. What is a hypertext link?
Ans. Hypertext link allows one page to navigate to another page.
              For Example:
             <html>
            <head>
     <title>This is the hypertext link example </title>
            </head>
           <body>
                 <a href=”http://sapnagiyanwani.blogspot.in”>Anchor tag example</a>
          </body>
           </html>

     15. What will be the output if you did not use the end tag?
Ans. The output will be same.

16. Where do we use keywords in HTML for search engine rankings?
Ans. In meta tag as below:
               <meta name=keywords content="your keywords here">

       17. Do older HTML files work on newer browsers?
Ans. Yes

      18. What is Anchor tag in HTML?
 Ans. Anchor tag can be used to link two sections or two web pages. The syntax for the Anchor tag is as below.
           <a href=”#” target=”_blank”></a>

      19. What are HTML Headings?
Ans. <h1> to <h6> defines the HTML Headings.
               <html>
               <head>
<title>This is the Heading  tag example </title>
               </head>
               <body>
<h1> This is heading 1 </h1>
<h2> This is heading 2 <h2>
            <h3>This is heading 3 <h3>
               </body>
               </html>

      20. What are HTML Attributes?
Ans. Any HTML element can have attributes; it provides more information about the element
              For example: src tag in image element and href tag in anchor tag.

      21. Define HTML paragraphs.
Ans. <p> tag in HTML defines the paragraphs.
                <p> This is the paragraph tag </p>

     22. Define HTML style attribute with example.
Ans.  The style attribute is used for styling any HTML element.
               For example:
               <html>
                <head>
<title>This is the style attribute example </title>
   </head>
              <body>
<p style=”color:red;”> Test for the style attribute </p>
              </body>
              </html>

      23. What is <iframe> ?
Ans. <iframe> is used to display a web page within the web page.
              <html>
  <head>
<title>This is the iframe example </title>
 </head>
             <body>
 <iframe src=”iframe.html”> </iframe>
              </body>
              </html>
      24. HTML images
Ans. <img> HTML tag is used to display the images in the web page.
               <html>
   <head>
<title>This is the iframe example </title>
  </head>
              <body>
  <img src="image.png" />
              </body>
              </html>

      25. How to create mailto link in HTML?
Ans. <a href=”mailto:sapnagiyanwani@gmail.com” >Send Mail</a>

26. What is a fieldset?
Ans . <fieldset> tag is used to group the related HTML tags.

27. What are HTML forms?
Ans. HTML forms are used to send information to the server.
              <html>
<head>
<title>This is the iframe example </title>
</head>
            <body>
<img src="image.png" />
            </body>
      </html>

28. Which HTML tag is used to display the data in tabular form?
Ans.  HTML <table> tag.

29.   Define the structure of <table> tag with example?
Ans.
    <html>
                <head>
                        <title>This is the table tag example </title>
                </head>
    <body>
                <table>
                 <tr>
                    <td>Name: </td>
                    <td>Sapna Shah</td>
                 </tr>
                </table>
    </body>
    </html>


  30.   What is colspan attribute?
  Ans.  colspan attribute is used to span two columns.

31. What is rowspan attribute?
Ans. rowspan attribute is used to span two rows.

32. What is DHTML?
Ans. DHTML is the combination of HTML, Javascript, and css like navigation menu.

33. How to align <table> tag to right in HTML?
Ans. <table table="right">

34. Does HTML support Javascript?
Ans. Yes

35. How to use Javascript in HTML?
Ans. We can use Javascript in HTML using <script> tag.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <script type="text/javascript">alert('Hi Sapna')</script>
</body>
</html>


36. How to focus the textbox of the form using HTML and Javascript?

Ans. 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
<form id="form1" name="form1">
<input type="text" id="txtname" name="txtname"/>
</form>
    <script type="text/javascript">
document.form1.txtname.focus();
</script>
</body>
</html>

37. How to open a link in a new tab?

Ans. <a href="https://sapnagiyanwani.blogspot.com/" _target="blank"></a>

38. How to change the background color of the page?

Ans. <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body bgcolor="yellow">
<form id="form1" name="form1">
<input type="text" id="txtname" name="txtname"/>
</form>
    <script type="text/javascript">
document.form1.txtname.focus();
</script>
</body>
</html>

39. How to create a telephone link in HTML?

Ans. <a href="tel:+917405743321" >Contact me </a>

40. What are the empty elements in HTML?

Ans. <br> and <hr> tag

No comments:

Post a Comment

Thanks

SQL server tricky questions