30 html interview questions and answers

HTML interview questions and answers for freshers and experienced candidates. Also find HTML online practice tests to fight written tests and certification exams on HTML. In this section we have covered almost all HTML questions that might be asked during an interview.
Ask a question
          

Html interview questions and answers

Part 1   Part 2   Part 3   Part 4   Part 5
<<Previous  Next>>

QUESTION - iframe in HTML is used to display a web page within a web page.

-True
-False
View Answer / Hide Answer

ANSWER - True

HTML5 online interview test (60 questions)
-By Pradip Patil, Lecturer IIMP MCA

QUESTION - An HTML file written in notepad can be saved with an extension:

-.htm
-.html
-Any of the above
-None of the above.

View Answer / Hide Answer

ANSWER - Any of the above

QUESTION - Which of the following is true about links by default?

-An unvisited link is underlined and blue.
-A visited link is underlined and red.
-An active link is underlined and purple.
-All the above.

View Answer / Hide Answer

ANSWER - An unvisited link is underlined and blue.

QUESTION - The href attribute in the link tag specifies the:

-Destination of a link.
-Link.
-Hypertext
-None of the above

View Answer / Hide Answer
ANSWER - Destination of a link.

QUESTION - HTML Event Attributes onload fires just before the page is finishing loading.

-True
-False

View Answer / Hide Answer

ANSWER - False

QUESTION - HTML Event Attributes onunload fires

-when the browser window has been closed
-when the browser window is minimized
-when the browser window has changed focus to other window.
-After the page is finished loading

View Answer / Hide Answer

ANSWER - when the browser window has been closed

QUESTION - HTML Form Events ___________, fires the moment that the element loses focus.

-onblur
-onfocus
-onchange
-onlostfocus

View Answer / Hide Answer

ANSWER - onblur

QUESTION - Which of the following tags below are used for a multi-line text input control?

-textml tag
-text tag
-textarea tag
-Both b and c above

View Answer / Hide Answer

ANSWER - textarea tag

QUESTION - What is cell padding?

-Used to separate cell walls from their contents.
-Used to set space between cells
-Both a and b above
-Used to provide width to a cell

View Answer / Hide Answer

ANSWER - Used to separate cell walls from their contents.

QUESTION - What are meta tags used for?

-To store information usually relevant to browsers and search engines.
-To only store information usually relevant to browsers
-To only store information about search engines.
-To store information about external links

View Answer / Hide Answer

ANSWER - To store information usually relevant to browsers and search engines.

QUESTION - When you use a heading tag in a document, what does the Web browser assume?

-Heading information is to appear in bold letters
-Heading information is to appear on its own line
-Heading information has a hyperlink
-Heading information is shown as a size six

View Answer / Hide Answer
ANSWER - Heading information is shown as a size six

QUESTION - What is the difference between XML and HTML?

-HTML is used for exchanging data, XML is not.
-XML is used for exchanging data, HTML is not.
-HTML can have user defined tags, XML cannot

View Answer / Hide Answer
ANSWER - XML is used for exchanging data, HTML is not.

QUESTION - What is mean by DTD?

-Document type data
-Data type definition
-Document type definition
-Definition type document

View Answer / Hide Answer

ANSWER - Document type definition

QUESTION - DOM stands for

-Document object model
-Data object model
-Document Oriented model
-Data oriented model

View Answer / Hide Answer

ANSWER - Document object model

QUESTION - Text/Html is called the __________ of the page

-content type
-MIME type
-content type/MIME type
-none of these

View Answer / Hide Answer

ANSWER - content type/MIME type

QUESTION - Which HTML attribute is used to define inline styles?

-font
-class
-styles
-style

View Answer / Hide Answer

ANSWER - style

QUESTION - Which is the correct CSS syntax?

-body:color=black
-{body;color:black}
-{body:color=black(body}
-body {color: black}

View Answer / Hide Answer

ANSWER - body {color: black}

QUESTION - What does an HTML tag do?

-It specifies formatting and layout instructions for your web page.
-It hides programming instructions from view.
-It determines the organizational structure of your Web site.
-It connects your web site to an operating environment.

View Answer / Hide Answer

ANSWER - It specifies formatting and layout instructions for your web page.

QUESTION - When you use a heading tag in a document, what does the Web browser assumes?

-Heading information is to appear in bold letters
-Heading information is to appear on its own line
-Heading information has a hyperlink
-Heading information is shown as a size six

View Answer / Hide Answer

ANSWER - Heading information is to appear on its own line

QUESTION - What is meant by the cellspacing attribute?

-It makes the cell span more than one column
-It specifies the space between the cell wall and the contents of the cell.
-It specifies the space between two cells.
-It makes the cell span more than one row

View Answer / Hide Answer

ANSWER - It specifies the space between two cells.

QUESTION - Which of the following attributes comes in handy when borders have to be put between groups of columns instead of every column?

-col
-colgroup
-rowspan
-row

View Answer / Hide Answer

ANSWER - colgroup

QUESTION - A few lines in an HTML paragraph are to be formatted differently from the rest of the lines. Which tag will assist in this?

-div
-p
-span
-format

View Answer / Hide Answer

ANSWER - p

HTML interview questions - posted on June 27, 2013 at 17:55 PM by Kshipra Singh

1. Do all HTML tags come in pair?

No, not all HTMLS tags come in pair. For e.g. <img>, <br>

2. What are some of the common lists that can be used when designing a page?

Some of the common lists that can be used are:

a.) Ordered list
b.) Unordered list
c.) Definition list
d.) Menu list
e.) Directory list

HTML5 interview questions and answers

3. What is the advantage of collapsing white space?

- The browser collapses the multiple white spaces into a single white space in HTML.
- This allows the developers to arrange the HTML code in a well organized and legible format.

4. Is it possible to list elements straight in an html file?

- Yes, it is possible with the use of indents. 

5. Does a hyperlink apply only to text?

- No. The hyperlinks can be applied to both text as well as the images.
- It means that even the images can become clickable links with a capability to take the visitor to the next page.
- This can be done simply by using <a href> tag.

6. What hierarchy is being followed when in style sheets?

- Inline style takes priority over embedded style sheets.
- Embedded style take priority over external style sheets.
- If a single selector includes three different style definitions, the definition that is closest to the actual tag gets the priority.

7. What happens if the list-style-type property is used on a non-list element like a paragraph?

- Here the property will be ignored without having any effect on the paragraph.

8. What is the advantage of using frames?

- Frames make it easier to navigate through a site.
- The links that appear in the frame can appear through out the site.

9. How can I hide my source?

- No. you can’t hide your source as it is required by the browser to display your document.

10. How will you align a table to the right or left?

- To align the table to the right, you can use <TABLE ALIGN="right">
- To align the table to the left, you can use <TABLE ALIGN="left">

11. Why doesn't <TABLE WIDTH="100%"> use the full browser width?

- This is because the graphical browser is designed to leave a margin between the display area and actual content.
- The navigator also leaves some space for the scroll bar on the right side of the display area. Though, if the page is not long enough, the scroll bar doesn’t appear.

12. How would you automatically transfer your visitors to a new web page?

- You can do it with the help of meta tag mentioned below:

<META HTTP-EQUIV="Refresh" CONTENT="2"; URL="http://www.yourname.com">

- Place this tag between <HEAD></HEAD> .
- It will load yousite.com in 2 seconds.

13. You want only a vertical scrollbar and no horizontal scrollbar on your page. How would you do it?

- This can be done by defining the frame with SCROLLING = auto and having content to just fit into this frame.
- SCROLLING="yes" gets the scroll bar on both the sides, even when not needed.
- SCROLLING="no" doesn’t get the scrollbars at all, even when they are needed.

14. How do you refer to the .css file in the web page?

- .css file in the web page can be referred with the use of <link> tag.
- It should be kept between <head></head> tag.
- Eg. <link href="/css/mystyle.css" type="text/css" rel="stylesheet" />

15. What is a better way to design the layout of a web page – a table tag or div?

- The better way to design the layout of the webpage is by using the <div> tag.
- The <table> tag is used to present the data in tabular format.

16. What is a <dl> tag in HTML?

- <dl> is a definition list tag used in HTML.
- It is used with <dt> and <dd>.
- <dt> list the item while <dd> describes it.

17. What are empty HTML elements?

- HTML elements with no content are called empty elements.
- For eg. <br>

HTML interview questions and answers - contributed by Rohit Srivastava

How to create nest tables within tables in HTML?

We can create nest table i.e. table inside a table. To create table we use following attributes:

<table>……</table>: declare starting and ending of table.
<tr>…</tr>: declare table row.
<td>…</td>: table data.

<table>
       <tr>
             <td>first cell of the outer table</td>
             <td>second cell of the outer table,
                                creating second table inside the first table
                                   <table>
                                           <tr>
                                                      <td>first cell of the second table</td>
                                                               <td>second cell of the second table</td>
                                            </tr>
                                   </table>
              </td>
        </tr>
</table>

Explain Non Breaking space in HTML.

When we add many spaces in the content then HTML remove all space except one space this is Non Breaking Space. To overcome this problem we use “&nbsp”. Suppose we want to add 3 space between two words then we have to use &nbp three time.

Example:

actual code:- hello I m Rohit Srivastava.
Display as:- Hello I m Rohit Srivastava.
But when we use &nbsp:
Actual code:- Hello &nbsp; &nbsp ; &nbsp; I m Rohit Srivastava.
Display as:- Hello I m Rohit Srivastava

How do I link to a location in the middle of an HTML document?

We can link to a location in the middle of an HTML document. Using Following steps:

  • Label the destination of the link. There are two ways of labeling destination using Anchor:
    o NAME attribute:
    Example: <h2><a name="destination">Destination: Explanation</a></h2>
    o ID attribute:
    Example: <h2 id="Destination_ID"> Destination: Explanation </h2>
  • Link to the labeled destination: we can link with the destination in the same URL page and with Different URL page.
    Example:
    Same URL: <a href="#Destination"> Visit to destination</a> or
    Different URL: <a href="thesis.html#section2">go to Section 2 of my thesis</a>

Explain Cell Padding and Cell Spacing.

Cell Padding: it refers to the gap or space between the cell content and cell border or cell wall.
Cell Spacing: It refers to the gap between the two cells of same tables.

In HTML cell spacing and padding both are used with Table Border layout.

Example:

<table border cellpadding=2>
<table border cellspacing=2>
<table border cellpadding=2 cellspacing=2>

How to create a button which acts like a link?

To create buttons which act as a hyperlink, there are two ways:

  • <FORM ACTION="[url]" METHOD=get>
    <INPUT TYPE=submit VALUE="Text on button">
    </FORM>
  • <INPUT TYPE="submit" VALUE="Go to my link location"
    ONCLICK=" http://www.careerride.com/;" />

What is difference between HTML and XHTML?

The differences between HTML and XHTML are:

  • HTML is application of Standard Generalized Markup Language(SGML) whereas XML is application of Extensible Markup Language(XML).
  • HTML is a static Web Page whereas XHTML is dynamic Web Page.
  • HTML allows programmer to perform changes in the tags and use attribute minimization whereas XHTML when user need a new markup tag then user can define it in this.
  • HTML is about displaying information whereas XHTML is about describing the information

How many types CSS can be include in HTML?

There are three ways to include the CSS with HTML:

  • Inline CSS: it is used when only small context is to be styled.
    o To use inline styles add the style attribute in the relevant tag.
  • External Style Sheet: is used when the style is applied to many pages.
    o Each page must link to the style sheet using the <link> tag. The <link> tag goes inside the head section:
    <head>
    <link rel="stylesheet" type="text/css" href="mystyle.css" />
    </head>
  • Internal Style Sheet: is used when a single document has a unique style.
    o Internal styles sheet needs to put in the head section of an HTML page, by using the <style> tag, like this:
    <head>
    <style type="text/css">
    hr {color:sienna}
    p {margin-left:20px}
    body {background-image:url("images/back40.gif")}
    </style>
    </head>

What are logical and physical tags in HTML?

Logical tags are used to tell the meaning of the enclosed text. The example of the logical tag is <strong> </strong> tag. When we enclosed text in strong tag then it tell the browser that enclosed text is more important than other text.

Physical text are used to tell the browser that how to display the text enclosed in the physical tag.
Some example of the physical tags are: <b> , <big> , <i>

Does HTML support Javascripts?

Yes, HTML supports JavaScripts. We can use JavaScript anywhere in the HTML Coding. Mainly there are four sections where we can add JavaScript in HTML.

  • Head Section: we can add JavaScript in Head section of HTML.
    <head>…..Javascript…. </head>
  • Body Section: <body>….. Javascript…</body>
  • Head and Body both: we can add Javascript in both head and body section.
    <body….Javascript…</body> and <head>…..Javascript…. </head>
  • External File: script in and external file and then include in <head> ….. </head> section.

Explain marquee tag.

Marquee tag: Marquee tag is used when we want that some text or content move in the web page whether horizontally or vertically.

Syntax of Marquee tag: <marquee>move text</marquee>

Attribute of Marquee tag are: bgcolor, direction, height, width, vspace etc.

How do I add midi music to my web page?

We can add midi Music in our HTML web page using following tag:
<bgsound src="music.mid" loop="1">

Attribute LOOP= 1: shows that music.mid is played only for one time. We can also set the value of loop to infinite. This tag is supported by Netscape and Internet Explorer.

Example: <embed src="canyon.mid" Autostart=TRUE Width=145 Height=60 Loop=true>

What are new Media Elements in HTML5?

Following are the New Media Elements are present in HTML5:

  • <audio> tag: for playing audio.
  • <video> tag: for playing video.
  • <source> tag: For media resources for media elements.
  • <embed> tag: For embedded content,
  • <track> tag: For text tracks used in media players

Explain various HTML list tags.

In HTML we can list the element in two ways:

  • Ordered list: in this list item are marked with numbers.
    Syntax: <ol>
    <li> first item </li>
    <li>second item </li> </ol>
    Display as: 1. First item
    2. Second item.
  • Unordered Lists: in this item are marked with bullets.
    Syntax: <ul>
    <li> first item </li>
    <li>second item </li> </ul>
    Display as:
    -First item
    -Second item.

Explain HTML background.

There are two types of background in HTML:

  • Colored Background: in this the background of the html is colored.
    The Syntax is: <body bgcolor = “red”>
    The value of the bgcolor can be set in three ways by hexadecimal number, an RGB value and Color name.
    Example: <body bgcolor = “black”>
    <body bgcolor = “rgb(0,0,0)”>
    <body bgcolor = “#000000”>
  • Image Background: in this we set the background of the website by an image. Syntax used for this is : <body background=”study.gif”>

What is CSS?

CSS stands for Cascading Style Sheets. By using CSS with HTML we can change the look of the web page by changing the font size and color of the font. CSS plays an important role in building the website. Well written CSS file can be used to change the presentation of each web page. By including only one CSS file. It gives web site developer and user more control over the web pages.

What is difference between HTML and HTML5?

The differences between HTML and HTML5 are:

  • Document of HTML is very large as compare to the HTML5.
  • Audio and Video tags are not present in HTML whereas HTML5 contains audio and video tags.
  • Vector technology is not integral part of HTML whereas HTML5 Vector technology is the integral part of it.
  • HTML supported by all old browsers whereas HTML5 is supported by new browser.
  • In HTML web sockets are not available whereas in HTML5 Full duplex communication channel is present.

How to insert Javascript in HTML?

We can insert JavaScript in HTML using <Script tag>. JavaScript can be enclosed in <script type = text/javascript> and ending with </script>.

Example:

<html>
  <body>
        <script type="text/javascript">
               ...JavaScript….
         </script>
   </body>
</html>

What is the Use of SPAN in HTML and give one example?

SPAN: Used for the following things:

  • Highlight the any color text
  • For adding colored text
  • For adding background image to text.

Example:

<p>
<span style="color:#000000;">
In this page we use span.
</span>
</p>

1.Define URL.

Uniform Resource Locator; an address that specifies the location of a file on the Internet...................
Read answer

2. Explain the general layout HTML documents.

Following is how the basic HTML layout:  <html><head><title>Title of page</title>.................
Read answer

3. What are various list tags in HTML?

<li>
Defines a list item
<ol>
Defines an ordered list..............
Read answer

4. What are the various text formatting tag in HTML?

<b>
Defines bold text
<br>
Inserts a single line break
<center>
Deprecated. Defines centered text
<em>...................
Read answer

5. Explain anchor tag in HTML.

The <a> tag defines an anchor. It can be used to create a link to another document by using the href attribute or to create a bookmark inside a document,................
Read answer

6. What is image mapping in HTML?

Making one image link to several pages is called as image mapping.
For example, if you have a map of India , then clicking..............
Read answer

7. Explain meta tag in HTML.
8. How to read and write a file using javascript?

There are two ways to do it: 1. Using JavaScript extensions (runs from JavaScript Editor), or 2. Using a web page and ActiveX objects (Internet Explorer only).................
Read answer

9. How do you create a new object in JavaScript?

The <meta> element provides meta-information about your page, such as descriptions....................
Read answer

Test your HTML knowledge with our multiple choice questions!
<<Previous  Next>>
XHTML Interview questions and Answers

  1. Define URL.
  2. Explain the general layout HTML documents.
  3. What are various list tags in HTML?
  4. What are the various text formatting tag in HTML?
  5. Explain anchor tag in HTML.
  6. What is image mapping in HTML?
  7. Explain meta tag in HTML.



Write your comment - Share Knowledge and Experience

Discussion Board
HTML interview questions and answers

How will you display a picture in background of HTML?
By using the tag: <body style="background-image:url(image path)">

How will you blink text in IE6?
By using the tag: <blink>Blink this text</blink>

Rahul 12-5-2011 07:10 AM

HTML interview questions and answers

How many color names are recognised by HTML?
16

How would you center a table in HTML?
<div class="center">
<table>...</table>
</div>

What are the tags to create lists in HTML?
<ul> - unordered list
<ol> - ordered list

Anupam 12-5-2011 07:09 AM

HTML interview questions and answers

I want to link an image to something. How do I do that?
Use the image as the link content: <a href=...><img src=... alt=...></a>

Syntax for marquee tag.
<marquee>Marquee this text</marquee>

Preeti 12-5-2011 07:08 AM

HTML interview questions and answers

How can I create a link?
<a href ="....">Link this</a>


shipra 12-5-2011 06:32 AM

 



 
 
Home | Login | About us | Sitemap | Contact us