FREE Web Template Download

Top 50 HTML Interview Questions

Top HTML Interview Questions & Answers

1) What is HTML?

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.

2) What are tags?

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:




3) Do all HTML tags come in pair?

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

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

You can insert any or a combination of the following list types:
– ordered list
– unordered list
– definition list
– menu list
– directory list
Each of this list types makes use of a different tag set to compose

5) How do you insert a comment in html?


Comments in html begins with “”. For example:



6) Do all character entities display properly on all systems?

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.

7) What is image map?

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.

8 ) What is the advantage of collapsing white space?

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.

9) Can attribute values be set to anything or are there specific values that they accept?

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.

10) How do you insert a copyright symbol on a browser page?

To insert the copyright symbol, you need to type © or & #169; in an HTML file.

11) How do you create links to sections within the same page?

Links can be created using the tag, with referencing through the use of the number (#) symbol. For example, you can have one line as BACK TO TOP, which would result in the words “BACK TO TOP” appearing on the webpage and links to a bookmark named topmost. You then create a separate tag command like somewhere on the top of the same webpage so that the user will be linked to that spot when he clicked on “BACK TO TOP”.

12) Is there any way to keep list elements straight 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.

13) If you see a web address on a magazine, to which web page does it point?

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.

14) What is the use of using alternative text in image mapping?

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.

15) Do older html files work on newer browsers?

Yes, older html files are compliant to the HTML standard. Most older files work on the newer browsers, though some features may not work.

16) Does a hyperlink apply to text only?

No, hyperlinks can be used on text as well as images. That means you can convert an image into a link that will allow user to link to another page when clicked. Just surround the image within the tag combinations.

17) If the user’s operating system does not support the needed character, how can the symbol be represented?

In cases wherein their operating system does not support a particular character, it is still possible to display that character by showing it as an image instead.

18) How do you change the number type in the middle of a list?

  • tag includes two attributes – type and value. The type attribute can be used to change the numbering type for any list item. The value attribute can change the number index.

    19) What are style sheets?

    Style sheets enable you to build consistent, transportable, and well-defined style templates. These templates can be linked to several different web pages, making it easy to maintain and change the look and feel of all the web pages within a site.

    20) What bullet types are available?

    With ordered lists, you can select to use a number of different list types including alphabetical and Roman numerals. The type attribute for unordered lists can be set to disc, square, or circle.

    21) How do you create multicolored text in a webpage?

    To create text with different colors, use the … tags for every character that you want to apply a color. You can use this tag combination as many times as needed, surrounding a single character or an entire word.

    22) Why are there both numerical and named character entity values?

    The numerical values are taken from the ASCII values for the various characters, but these can be difficult to remember. Because of this, named character entity values were created to make it easier for web page designers to use.

    23) Write a HTML table tag sequence that outputs the following:
    50 pcs 100 500
    10 pcs 5 50




    50 pcs 100 500
    10 pcs 5 50

    24) What is the advantage of grouping several checkboxes together?

    Although checkboxes don’t affect one another, grouping checkboxes together helps to organize them. Checkbox buttons can have their own name and do not need to belong to a group. A single web page can have many different groups of checkboxes.

    25) What will happen if you overlap sets of tags?

    If two sets of html tags are overlapped, only the first tag will be recognized. You will recognize this problem when the text does not display properly on the browser screen.

    26) What are applets?

    Applets are small programs that can be embedded within web pages to perform some specific functionality, such as computations, animations, and information processing. Applets are written using the Java language.

    27) What if there is no text between the tags or if a text was omitted by mistake? Will it affect the display of the html file?

    If there is no text between the tags, then there is nothing to format, so no formatting will appear. Some tags, especially tags without a closing tag like the tag, do not require any text between them.

    28) Is it possible to set specific colors for table borders?

    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.

    29) How do you create a link that will connect to another web page when clicked?

    To create hyperlinks, or links that connect to another web page, use the href tag. The general format for this is:text
    Replace “site” with the actual page url that is supposed to be linked to when the text is clicked.

    30) What other ways can be used to align images and wrap text?

    Tables can be used to position text and images. Another useful way to wrap text around an image is to use style sheets.

    31) Can a single text link point to two different web pages?

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

    32) What is the difference between the directory and menu lists and the unordered list?

    The key differences is that the directory and menu lists do not include attributes for changing the bullet style.

    33) Can you change the color of bullets?

    The bullet color is always the same as that of the first character in the list litem. If you surround the

  • and the first character with a set of tags with the color attribute set, the bullet color and the first character will be a different color from the text.

    34) What are the limits of the text field size?

    The default size for a text field is around 13 characters, but if you include the size attribute, you can set the size value to be as low as 1. The maximum size value will be determined by the browser width. If the size attribute is set to 0, the size will be set to the default size of 13 characters.

    35) Do tags always need to come at the start of a row or column?

    Any tag can be changed to a tag. This causes the text contained within the tag to be displayed as bold in the browser. Although tags are mainly used for headings, they do not need to be used exclusively for headings.

    36) What is the relationship between the border and rule attributes?

    Default cell borders, with a thickness of 1 pixel, are automatically added between cells if the border attribute is set to a nonzero value. Likewise, If the border attribute is not included, a default 1-pixel border appears if the rules attribute is added to the tag.

    37) What is a marquee?

    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 and tags.

    38) How do you create a text on a webpage that will allow you to send an email when clicked?

    To change a text into a clickable link to send email, use the mailto command within the href tag. The format is as follows:


    text to be clicked

    39) Are
    tags the only way to separate sections of text?

    No. The
    tag is only one way to separate lines of text. Other tags, like the

    tag and

    tag, also separate sections of text.


    40) Are there instances where text will appear outside of the browser?

    By default, the text is wrapped to appear within the browser window. However, if the text is part of a table cell with a defined width, the text could extend beyond the browser window.

    41) How are active links different from normal links?

    The default color for normal and active links is blue. Some browsers recognize an active link when the mouse cursor is placed over that link; others recognize active links when the link has the focus. Those that don’t have a mouse cursor over that link is considered a normal link.

    42) Do style sheets limit the number of new style definitions that can be included within the brackets?

    Style sheets do not limit the number of style definitions that can be included within the brackets for a given selector. Every new style definition, however, must be separated from the others by a semicolon symbol.

    43) Can I specify fractional weight values such as 670 or 973 for font weight?

    Implementation largely depends on the browser, but the standard does not support fractional weight values. Acceptable values must end with two zeroes.

    44) What is the hierarchy that is being followed when it comes to style sheets?

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

    45) Can several selectors with class names be grouped together?

    You can define several selectors with the same style definition by separating them with commas. This same technique also works for selectors with class names.

    46) What happens if you open the external CSS file in a browser?

    If you try to open the external CSS file in a browser, the browser cannot open the file, because the file has a different extension. The only way to use an external CSS file is to reference it using tag within another html document.

    47) How do you make a picture into a background image of a web page?

    To do this, place a tag code after the tag as follows:



    Replace image.gif with the name of your image file. This will take the picture and make it the background image of your web page.

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

    If the list-style-type property is used on a non-list element like a paragraph, the property will be ignored and have no effect on the paragraph.

    49) When is it appropriate to use frames?

    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.

    50) What happens if the number of values in the rows or cols attribute doesn’t add up to 100 percent?

    The browser sizes the frames relative to the total sum of the values. If the cols attribute is set to 100%, 200%, the browser displays two vertical frames with the second being twice as big as the first.

    HTML Interview Questions

    A list of top frequently asked HTML interview questions and answers are given below.

    1) What is HTML?

    HTML stands for Hyper Text Markup Language. It is a language of World Wide Web. It is a standard text formatting language which is used to create and display pages on the Web.

    2) What are Tags?

    HTML tags are composed of three things: opening tag, content and ending tag. Some tags are unclosed tags.

    HTML documents are made of two things:

    • content, and
    • tags

    Content is placed between tags to display data on the web page.

    3) Do all HTML tags have end tag?

    No. There are some HTML tags that don't need a closing tag. For example: tag,

    4) What are some common lists that are used when designing a page?

    There are many common lists which are used to design a page. You can choose any or a combination of the following list types:

    • Ordered list
    • Unordered list
    • Menu list
    • Directory list
    • Definition list

    5) What is the difference between HTML elements and tags?

    HTML elements communicate to the browser to render text. When the elements are surrounded by brackets <>, they form HTML tags. Most of the time, tags come in pair and surround content.

    6) What is semantic 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 tag is not used for bold statement as well as tag is used for italic. Instead of these we use and tags.

    7) What is image map?

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

    8) How to insert a copyright symbol on a browser page?

    can insert a copyright symbol by using © or © in an HTML file.

    9) How do you keep list elements straight in an HTML file?

    You can keep the list elements straight by using indents.

    10) Does a hyperlink only apply to text?

    No, you can use hyperlinks on text and images both.

    11) What is a style sheet?

    A style sheet is used to build a consistent, transportable, and well designed style template. You can add these templates on several different web pages.

    12) Can you create a multi colored text on a web page?

    Yes. To create a multicolor text on a web page you can use for the specific texts you want to color.

    13) Is it possible to change the color of the bullet?

    The color of the bullet is always the color of the first text of the list. So, if you want to change the color of the bullet, you must change the color of the text.

    14) What is a marquee?

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

    15) How many tags can be used to separate section of texts?

    There are three tags used to separate the texts. i.e. usually
    tag is used to separate line of texts. Other tags are

    tag and


    16) How to make a picture a background image of a web page?

    To make a picture a background image on a web page, you should put the following tag code after the tag.

    1. <body background = "image.gif">  

    Here, replace the "image.gif" with the name of your image file which you want to display on your web page.

    17) What are empty elements?

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


    18) What is the use of span tag? Give one example.

    The span tag is used for following things:

    • For adding color on text
    • For adding background on text
    • Highlight any color text etc.


    1. <p>  
    2. <span style="color:#ffffff;">  
    3. In this page we use span.  
    4. span>  
    5. p>  

    19) What is the use of iframe tag?

    An iframe is used to display a web page within a web page.


    1. <iframe src="URL">iframe>  


    1. <iframe src="demo_iframe.html" width="200px" height="200px">iframe>  

    Target to a link:

    1. <iframe src="http://www.thebesttutorials" name="iframe_a">iframe>  

    HTML5 Interview Questions

    Let's see a list of top HTML5 interview questions and answers.

    20) What is canvas in HTML5?

    Canvas is an HTML area which is used to draw graphics.

    21) What is SVG?

    HTML SVG is used to describe the two dimensional vector and vector/raster graphics.

    22) What are the different new form element types in HTML 5?

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

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

    23) Is there any need to change the web browsers to support HTML5?

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

    24) Which video formats are supported by HTML5?

    HTML 5 supports three types of video format:

    • mp4
    • webm
    • ogg

    25) Is audio tag supported in HTML 5?

    Yes. It is used to add sound or music files on the web page.

    26) What is the difference between progress and meter tag?

    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.

    27) What is the use of figure tag in HTML 5?

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

    28) What is button tag?

    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.

    29) What does details and summary tag?

    The details tag is used to specify some additional details on the web page. It can be viewed or hidden on demand. The summary tag is used with details tag.

    30) What is datalist tag?

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

    31) How tags are migrated from HTML4 to HTML5?


    Typical HTML4

    Typical HTML5






















    Header and Footer Example

    HTML 4 Header and Footer:

    1. <div id="header">  
    2.   <h1>Monday Timesh1>  
    3. <div id="footer">  
    4.   <p>© JavaTpoint. All rights reserved.p>  
    5. div>  

    HTML 5 Header and Footer:

    1. <header>  
    2.   <h1>Monday Timesh1>  
    3. header>  
    4. .  
    5. .  
    6. .  
    7. <footer>  
    8.   <p>© JavaTpoint. All rights reserved.p>  
    9. footer>  

    Menu Example

    HTML 4 Menu:

    1. <div id="menu">  
    2.   <ul>  
    3.     <li>Newsli>  
    4.     <li>Sportsli>  
    5.     <li>Weatherli>  
    6.   ul>  
    7. div>  

    HTML 5 Menu:

    1. <nav>  
    2.   <ul>  
    3.     <li>Newsli>  
    4.     <li>Sportsli>  
    5.     <li>Weatherli>  
    6.   ul>  
    7. nav>  

    32) If I do not put will HTML 5 work?

    No, browser will not be able to identify that it is a HTML document and HTML 5 tags will not function properly.

    33) What is the use of required attribute in HTML5?

    It forces user to fill text on textfield or textarea before submitting form. It is used for form validation.


    1. Name: <input type="text" name="name" required>  

    34) What are the new types for form validation in HTML5?

    The new input types for form validation are email, url, number, tel and date.


    1. <input type="email">  

      HTML Interview Questions and Answers - Freshers & Experienced

      Do all HTML tags come in pair?

      No, not all HTMLS tags come in pair. For e.g. ,

      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

      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.

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

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

      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 tag.

      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.


      Main Title

      This is my page
      : It is used as a block element and is defined to group HTML elements together in one. The
      tag is used to create multiple layouts. 

      The sample code is given as:



      Main Title of Web Page



      The elements that are used in this tag is as follows:

      1. BGCOLOR : Represents the background color which will be applied totally on the body if there is no other bgcolor used with any other tag internally.
      2. TEXT : Represents the color of the text that will be applied to the complete text present in the body.
      3. LINK : Represents the color of all the text links that are present inside the body.
      4. VLINK : Represents the color of the links that has already been visited.
      5. ALINK : Represents the color of the text links that


      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.

      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.

      How can I hide my source?

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

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

      - To align the table to the right, you can use
      - To align the table to the left, you can use


      The value of the bgcolor can be set in three ways by hexadecimal number, an RGB value and Color name.