HTML Interview Questions

HTML is short for HyperText Markup Language, and is the language of the World Wide Web. It is the standard text formatting language used for creating and displaying pages on the Web. HTML documents are made up of two things: the content and the tags that formats it for proper display on pages.

Content is placed in between HTML tags in order to properly format it. It makes use of the less than symbol (<) and the greater than symbol (>). A slash symbol is also used as a closing tag. For example:

<strong> sample </strong>

No, there are single HTML tags that does not need a closing tag. Examples are the tag and

Comments in html begins with “

<!–“-- “–>”.
For example:

<!-- compuhelp -->

No, there are some character entities that cannot be displayed when the operating system that the browser is running on does not support the characters. When that happens, these characters are displayed as boxes.

Image map lets you link to many different web pages using a single image. You can define shapes in images that you want to make part of an image mapping.

White spaces are blank sequence of space characters, which is actually treated as a single space character in html. Because the browser collapses multiple space into a single space, you can indent lines of text without worrying about multiple spaces. This enables you to organize the html code into a much more readable format.

Some attribute values can be set to only predefined values. Other attributes can accept any numerical value that represents the number of pixels for a size.

To insert the copyright symbol, you need to type © in an HTML file.

By using indents, you can keep the list elements straight. If you indent each subnested list in further than the parent list that contains it, you can at a glance determine the various lists and the elements that it contains.

Every web page on the web can have a separate web address. Most of these addresses are relative to the top-most web page. The published web address that appears within magazines typically points this top-most page. From this top level page, you can access all other pages within the web site.

When you use image maps, it can easily become confusing and difficult to determine which hotspots corresponds with which links. Using alternative text lets you put a descriptive text on each hotspot link.

You can specify a border color using style sheets, but the colors for a table that does not use style sheets will be the same as the text color.

No. The

tag can accept only a single href attribute, and it can point to only a single web page.

A marquee allows you to put a scrolling text in a web page. To do this, place whatever text you want to appear scrolling within the <marquee> and </marquee> tags.
No. The <br> tag is only one way to separate lines of text. Other tags, like the <p> tag and <blockquote> tag, also separate sections of text.

Frames can make navigating a site much easier. If the main links to the site are located in a frame that appears at the top or along the edge of the browser, the content for those links can be displayed in the remainder of the browser window.

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.

1. Head Section : We can add JavaScript in Head section of HTML.
<head>…..Javascript…. </head>
2. Body Section : <body>….. Javascript…</body>
3. Head and Body both : We can add Javascript in both head and body section.
<body….Javascript…</body> and <head>…..Javascript…. </head>
4. External File : Script in and external file and then include in <head> …..  section.

Following are the New Media Elements are present in HTML5:

1. >audio< tag : For playing audio.
2. >video< tag : For playing video.
3. >source< tag : For media resources for media elements.
4. >embed< tag : For embedded content.
5. >track< tag : For text tracks used in media players.

In HTML we can list the element in two ways:

1. Ordered list : In this list item are marked with numbers.

<li> first item </li>
<li>second item </li></ol>

Display as:

1. First item

2. Second item.

2. Unordered Lists : In this item are marked with bullets.

<li> first item </li>
<li>second item </li></ol>

Display as:

- First item

- Second item.

SPAN : Used for the following things:

1. Highlight the any color text

2. For adding colored text

3. For adding background image to text.

<span style="color:#000000;">
In this page we use span.
Doctype tag is not a HTML tag, it is just an instruction that is passed to the web browser to check for the information that is being provided by the markup language in which the page is written. Doctype is sometimes referred as Document type definition (DTD) that describes some rules that has to be followed while writing the markup language so to make the web browser understand the language and the content correctly. Doctype is very important to be placed in the beginning of the HTML and before the <HTML> tag to allow easy rendering of the pages that are used.

Metadata is the data about the data or the information about the data. There is a tag <meta> that is being provided for the HTML document. This information won't be displayed anywhere and will not be visible to the user. It will be parsable by the machine which will parse it according to the requirement. It consists of the elements that are related to the page description, keywords, document related element. The tag that is being used resides in the  section in HTML. The meta information is being used by the web browser or by the search engines to rank and let the user find the pages easily. 
<meta name="description" content="Here you will get everything" />

Canvas is an element that is used for the graphics for the web page. It uses JavaScript to bring the graphics functionality live. It allows easy way to draw the graphics and use different types of tools to create drawing on the web page. Canvas is just a rectangular area that controls the pixel of every element that is used in the web page. Canvas uses methods like paths, circles, etc.

The canvas element will be used as follows:

<canvas id="can" width="200" height="100"></canvas>

The canvas element includes id, width and height settings and with the javascript it gets used like:

<script type="text/javascript">
var c=document.getElementById("can");
var ctx=c.getContext("2d");

Iframe is called as inline frame that places one HTML document in a frame. It is different from the object element as the inline frame can be made in the target frame. The target frame consists of the links that is defined by other elements used in the web page. Iframe is used to focus on printing or viewing of the source. Iframe can be used by the user in those browser that supports it. If they have used iframe also then the incompatible browser won't display the actual but display of the alternative text will take place.


<iframe> ----- </iframe>

"pre" tag defines the pre-formatted text that is used to display the text with the fixed width and uses a predefined fonts and it keeps both spaces and line breaks separate and show the text as it is.

The code that can be used to display the text that can be written in whatever way the user wants is as follows:

Text in a pre element ----//
is displayed in a fixed-width
font, and it preserves
both spaces and
line breaks

Tables can be made nested by making it come in another table. This consists of many attributes and tags that can be used in nesting the tables.

<td>this is the first cell</td>
<td>this is the second cell</td>
<td>this is the first cell second table</td>
<td>this is the second cell of second table</td>

Getting framed refers to the document that is being displayed in someone else's frameset in your HTML. This will be password protected and the permissions has to be taken before inserting the frameset. The framing of the document can be avoided by using TARGET=_top applied to all the links that will lead to the document that are outside the scope of a particular user without permission. A javaScript can be used that will automatically handle the request to remove the existing framesets. This can be given as:

<script type="text/javascript">
if (top.frames.length!=0) 
    if (window.location.href.replace)

One frameset can be defined inside another frameset if the accessing permission are provided directly. The frameset can be stored by using the JavaScript in the document that is being written by the user and the script is as follows:

<script TYPE="text/javascript">
if (parent.location.href == self.location.href) 
    if (window.location.href.replace)
       // causes problems with back button, but works
       window.location.href = 'frame.html';

Semantic HTML is a coding style. It is the use of HTML markup to reinforce the semantics or meaning of the content. For example: In semantic HTML

 <b> </b>
tag is not used for bold statement as well as
<i> </i> 
tag is used for italic. Instead of these we use

Marquee is used to put the scrolling text on a web page. You should put the text which you want to scroll within the


HTML elements with no content are called empty elements. For example:

<br> , <hr>

Following is a list of 10 important new elements in HTML 5:

  • Color
  • Date
  • Datetime-local
  • Email
  • Time
  • Url
  • Range
  • Telephone
  • Number
  • Search

No. Almost all browsers (updated versions) support HTML 5. For example: Chrome, Firefox, Opera, Safari, IE etc.

HTML 5 supports three types of video format:

  • mp4
  • webm
  • ogg

The progress tag is used to represent the progress of the task only while the meter tag is used to measure data within a given range.

The figure tag is used to add a photo in the document on the web page.

The button tag is used in HTML 5. It is used to create a clickable button within HTML form on the web page. It is generally used to create a "submit" or "reset" button.

The HTML 5 datalist tag provides an auto complete feature on form element. It facilitates users to choose the predefined options.