HTML Interview Questions and Answers

Q.1.How do you add a copyright symbol on a HTML page?
A.Copyright symbol can be either copied and pasted from other sources. Or, you can also add it by writing a small piece of code: © or & #169; in the required page.
Q.2.What is Geolocation API in HTML?
A.HTML5 Geolocation API lets you share your location with your favorite web sites. A Javascript can capture your latitude and longitude and can be sent to backend web server and do fancy location-aware things like finding local businesses or showing your location on a map.Today most of the browsers and mobile devices support Geolocation API. The geolocation APIs work with a new property of the global navigator object ie. Geolocation object which can be created as follows:
var geolocation = navigator.geolocation;
The geolocation object is a service object that allows widgets to retrieve information about the geographic location of the device.
Q.3. What does DOCTYPE mean?
A.DOCTYPE or Document Type Declaration is a type of instruction which usually works in association with particular SGML or XML documents basically. Let us take an example to understand it more thoroughly, for example, A Web page with a document type definition i.e. DTD is the best to understand. In a well serialized and a proper form of the document, It manifests and also the contribution of it is a lot as a short string of markup that usually conforms to a particular syntax.
Q.4. What is HTML and what is it used for?
A.HTML is a widely used language that gives our webpage a structure. HTML stands for HYPERTEXT MARKUP LANGUAGE. HTML was created by Berners lee in 1991. A markup language is a set of markups tags. Every webpage is created in HTML. HTML documents are described in HTML tags.
Q.5. What is a physical tag and logical tag in HTML?
A.  Physical tag has physical text which is used to tell the browser how to display the text enclosed in the physical tag.Example for the physical tags are: <big>, <b>, <i>Logical tags are used to tell the meaning of the enclosed text in it. The example of the logical tag is <Important>….</Important> tag. When we enclose text in Important tag then it tell the browser that enclosed text is more important than other text.
Q.6. What is the purpose of using alternative texts in images?
A.  The basic purpose of using alternative texts is to define what the image is about. During an image mapping, it can be confusing and difficult to understand what hotspots correspond to a particular link. These alternative texts come in action here and put a description at each link which makes it easy for users to understand the hotspot links easily.
Q.7.What is an image map?
A.Image mapping lets a user to link one image to different web pages in and out of the website. It is the process of defining special shapes inside an image and link it to different destinations.
Q.8. What isCell Spacing and Cell Padding?
A.Cell Spacing is referred to space/gap between the two cells of the same table.
Cell Padding is referred to the gap/space between the content of the cell and cell wall or Cell border.
Example:
<table border cellspacing=3>
<table border cellpadding=3>
<table border cellspacing=3 cellpadding=3>
Q.9.What is grouping in HTML?
A. Grouping is used to group several HTML controls like input, textarea, selects as well as labels ( <label>) within a web form. In HTML <fieldset> element is used for Grouping.

Q.10. What is the XHTML?
A.XHTML means Extensible Hypertext Markup Language, which is basically a part of Family of XML markup language. It usually extends the most popularly used HTML i.e. Hypertext Markup Language, the pages in which the web pages are formulated.
Q.11. How to create mailto link in HTML
A.Basically, when we usually start with a hyperlink that is Mailto rather than using HTTP or others, the browser should be able to compose an email in the visitor’s default email program on their computer. There are two ways to insert a mailto link into a HubSpot page or email, just by inserting a hyperlink into the rich editor or inputting into the source code. Option one is basically nothing just to insert a mailto link as a hyperlink, also highlight the text or click on the image as you wish.to apply on the mailto link to for your contacts or visitors to click on and finally click Add the link to finish. Option two is to Insert a mailto link into the source code and Click Save to finish then Publish or Update your page.
Q.12.What is the difference between DIV and SPAN in HTML?
A.The difference between span and div is that a span element is in-line and usually used for a small chunk of HTML inside a line (such as inside a paragraph) whereas a div (division) element is block-line (which is basically equivalent to having a line-break before and after it) and used to group larger chunks of code.
<p>This is <span class=”paper”>crazy</span></p>
</div>
Q.13.What is “Semantic HTML” ?
A.  Semantic HTML or Semantic Markup is HTML that introduces meaning to the web page rather than just presentation.<form><table>, and <article> are examples of Semantic Elements.Below are the list of few new Semantic Elements introducted HTML.

  • <article>
  • <aside>
  • <details>
  • <figcaption>
  • <figure>
  • <footer>
  • <header>
  • <main>
  • <mark>
  • <nav>
  • <section>
  • <summary>
  • <time>
Q.14.What is the difference between a tag and an element in HTML?
A.  HTML tag is just opening or closing entity.Example: <p> and </p> are called HTML tagsHTML element encompasses opening tag, closing tag, content (optional for content-less tags)Example: <p>This is the content</p> : This complete thing is called an HTML element
Q.15.List the media types and formats supported by HTML ?
A.  HTML supports a wide range of media formats for sound, music, videos, movies, and animations. Below is the list extensions supported by each media format.
Media Type Formats Supported
Images png, jpg, jpeg, gif, apng, svg, bmp, bmp ico, png ico
Audio MIDI, RealAudio, WMA, AAC, WAV, Ogg, MP3, MP4
Video MPEG, AVI, WMV, QuickTime, RealVideo, Flash, Ogg, WebM, MPEG-4 or MP4
Q.16.List the media types and formats supported by HTML ?
A.  In HTML, we have two types of lists unordered lists and ordered lists. Unordered list starts with <ul> tag and ends with </ul>tag. Ordered tag starts with <ol> and ends with </ol>. Each list item is written as <li></li>
Q.17. How are active links different from normal links?
A.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.
Q.18.  What is <figure> in HTML5?
A.This tag represents a piece of self-contained flow content. It is mostly used as a single unit as a reference the main flow of the document.
Q.19.What is the use of Canvas element?
A.The canvas element helps to build charts, graphs, bypass Photoshop to create 2D images and place them directly into HTML5 code.
Q.20.What are the new FORM elements which are available in HTML5?
A.The new Form elements in HTML5 offers much better functionality than the earlier versions.The new Form elements in HTML5 offers much better functionality than the earlier versions.The tags given provided to carry out these functions are:1) <datalist> – This tag is use to specify a list of options for input controls.2) <keygen> – This tag represents a key-pair generator field.3) <output> – It represents the result of any scripting calculation.
Q.21.Do all HTML tags have an end tag?
A.There are some HTML tags that don’t need a closing tag. For example: tag,
tag.
Q.22.What is formatting in HTML?
A.The HTML formatting is a process of format the text for a better look and feel. It uses different tags to make text bold, italicized, underlined.
Q.23.How to create a hyperlink in HTML?
A. The HTML provides an anchor tag to create a hyperlink that links one page to another page. These tags can appear in any of the following ways:

  • Unvisited link – It is displayed, underlined and blue.
  • Visited link – It is displayed, underlined and purple.
  • Active link – It is displayed, underlined and red.
Q.24.What are some common lists that are used when designing a page?
A. 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 – The ordered list displays elements in numbered format. It is represented by <ol> tag.
  • Unordered list – The unordered list displays elements in bulleted format. It is represented by <ul> tag.
  • Definition list – The definition list displays elements in definition form like in dictionary. The <dl>, <dt> and <dd> tags are used to define description list.
Q.25.What is a style sheet?
A. 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. It describes the look and formatting of a document written in markup language.
Q.26.Can you create a multi-colored text on a web page?
A. Yes. To create a multicolor text on a web page you can use for the specific texts you want to color.
Q.27.Is it possible to change the color of the bullet?
A. 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.
Q.28.What is a marquee?
A. Marquee is used to put the scrolling text on a web page. It scrolls the image or text up, down, left or right automatically. You should put the text which you want to scroll within the <marquee>……</marquee> tag.
Q.29.How many tags can be used to separate a section of texts?
A. Three tags are used to separate the texts.

  • <br> tag – Usually <br> tag is used to separate the line of text. It breaks the current line and conveys the flow to the next line
  • <p> tag – The <p> tag contains the text in the form of a new paragraph.
  • <blockquote> tag – It is used to define a large quoted section. If you have a large quotation, then put the entire text within <blockquote>………….</blockquote> tag.
Q.30.What are empty elements?
A. HTML elements with no content are called empty elements. For example: <br>, <hr> etc.
Q.31.What is the use of a span tag? Give one example.
A. The span tag is used for following things:

  • For adding color on text
  • For adding background on text
  • Highlight any color text
Q.32.What is the use of an iframe tag?
A. An iframe is used to display a web page within a web page.
Q.33.What are the entities in HTML?
A. The HTML character entities are used as a replacement for reserved characters in HTML. You can also replace characters that are not present on your keyboard by entities. These characters are replaced because some characters are reserved in HTML.
Q.34.Why is a URL encoded in HTML?
A. An URL is encoded to convert non-ASCII characters into a format that can be used over the Internet because a URL is sent over the Internet by using the ASCII character-set only. If a URL contains characters outside the ASCII set, the URL has to be converted. The non-ASCII characters are replaced with a “%” followed by hexadecimal digits.
Q.35.Does a <!DOCTYPE html> tag is a HTML tag?
A. No, the <!DOCTYPE html> declaration is not an HTML tag. There are many type of HTML e.g. HTML 4.01 Strict, HTML 4.01 Transitional, HTML 4.01 Frameset, XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1 etc. So, <!DOCTYPE html> is used to instruct the web browser about the HTML page.