Top 22.5 HTML Interview questions and answers for freshers pdf

codesparta html interview questions and answers for freshers

HTML stands for Hypertext Markup Language .

HTML  is the language for describing the structure of Web pages. HTML gives authors the means to:

  • Publish online documents with headings, text, tables, lists, photos, etc.
  • Retrieve online information via hypertext links, at the click of a button.
  • Design forms for conducting transactions with remote services, for use in searching for information, making reservations, ordering products, etc.
  • Include spread-sheets, video clips, sound clips, and other applications directly in their documents.


Rules for writing HTML code

  1. HTML is made of the markup tags , and each tag must have an opening and a closing , eg. <h1>Heading tag 1</h1> , but some exceptions are there like <br> .
  2. Proper nesting of tags : HTML elements can be nested which means that one element can have one or more elements inside them , here is an example how to nest html elements    —>>                   <b><i>Bold and Italics </i></b> , the tag started first will end last .
  3. Markup Additional Attribute : Any attribute should be  added within the opening tag only , for example , Giving ID to the heading tag <h1 id=”thisIsID”>Hello there</h1>


Top 22.5 html interview questions and answers for freshers and experienced as below :

1. What is HTML and what is the use of HTML ?

HTML Stands for HyperText Markup Language & it is the standard markup language used to create web pages.

2. What is Doctype in Html ?

Doctype tells the browser which type of HTML is used on a webpage.

3.  What are tags in HTML ?

Html is markup language , everything in html comes between these markups or tags , for example <h1> tag for heading , these tags generally come in pair which means that for every closing opening tag there must be closing tag . There are few exceptions like <br/> , <hr/> tags .

4. Write a code for simple page with a heading , an image and a paragraph .

5. What is the difference between <p> and <P> ?

There is no difference between p and P , both will give same result . HTML is not case-sensitive .

6. If I do not put <!DOCTYPE  html> will HTML 5 work?

No , the browser wont be able to identify it as valid HTML 5 document and HTML 5 Tags won’t work properly . The browser will fall back to the standard mode

7.  Comments in HTML?
Comment tags <!– and –> are used to insert comments in HTML.

8. How is the page structure of HTML 5 different from HTML 4 or previous HTML?

A typical webpage has elements like header , footer , sidebar etc . Before HTML 5 we had to make divs for different uses and give the id , but in HTML 5 we have different tags for header , footer , sidebar etc that has made html code navigation and writing easier .

Html interview questions and answers , html 4 and html 5 document structure diffrence

HTML 4 and HTML5 page structure difference

9. Explain Ordered and Unordered lists in html ?

Lists can be generally classified into two types : Ordered List and Unordered List


Ordered ListUnordered List
  1. Ordered List
  2. Ordered List
  3. Ordered List
  • Unordered List
  • Unordered List
  • Unordered List

Clearly the Ordered list are ordered according to numbers whereas the unordered is not . We have <ol> and <ul> for ordered and unordered lists respectively . ( Click the link below to read more )

READ MORE : HTML list element with examples (Code for Making and Customizing Lists)

10. What is the advantage of grouping several checkboxes together ?

Although checkboxes don’t affect one another, grouping checkboxes together helps to organize them.

11. How to make horizontal menu bar in HTML ?

Make horizontal menu bar by using list !!

We can also use lists to make horizontal menus in websites  that can be done by adding some css style called inline .

12. Can we have Nested HTML tags ?

Yes , the above code has <li> elements nested in the <ul> elements . Rule : <b><i>Bold and Italics </i></b> , the tag started first will end last .

13. There are how many way for Styling HTML with CSS?
Styling can be added to HTML elements in 3 ways:

  • Inline – using a style attribute in HTML elements
  • Internal – using a <style> element in the HTML <head> section
  • External – using one or more external CSS files

14. How to use external Javascript and CSS files in HTML ?

We can use external Javascript & CSS files in HTML by using the following code

15. Explain img element in HTML ?

The <img> tag is empty, it contains attributes only, and does not have a closing tag.

The src attribute defines the url (web address) of the image:
<img src=”url_of_the_image” alt=”some_text”>

You can use the style attribute to specify the width and height of an image.
The values are specified in pixels (use px after the value):


16. List the new HTML 5 tags / elements ?

Some of the following tags (elements)that have been introduced in HTML5 −

Tags (Elements)Description
<article>Represents an independent piece of content of a document, such as a blog entry or newspaper article
<aside >Represents a piece of content that is only slightly related to the rest of the page.
<audio>Defines an audio file.
<canvas>This is used for rendering dynamic bitmap graphics on the fly, such as graphs or games.
<command>Represents a command the user can invoke.
<time>Represents a date and/or time.
<embed>Defines external interactive content or plugin.
<figure>Represents a piece of self-contained flow content, typically referenced as a single unit from the main flow of the document.
<footer>Represents a footer for a section and can contain information about the author, copyright information, etc
<header>Represents a group of introductory or navigational aids.
<hgroup>Represents the header of a section.
<keygen>Represents control for key pair generation.
<video>Defines a video file.
<progress>Represents a completion of a task, such as downloading or when performing a series of expensive operations.
<ruby>Together with <rt> and <rp> allow for marking up ruby annotations.

17 . What is the meaning of &nbsp ?

&nbsp is an entity used in html to give non – breakable space , we use it when we have to give deliberately spaces inside of html that is uses more than one character space .

18. How to give Meta Information ?

We use Meta Tag , Example : Add Meta Information in HTML head tag .

19 . What will happen tags overlap ?

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.

20. Difference between GET and POST methods in HTML Forms

Difference between GET and POST methods Respectively :

VisibilityData is visible to everyone in the URLData is not displayed in the URL
Restrictions on data typeOnly ASCII characters allowedNo restrictions. Binary data is also allowed

GET is less secure compared to POST because data sent is part of the URL

POST is a little safer than GET because the parameters are not stored in browser history or in web server logs
Restrictions on data lengthYes , Max length is 2048 charactersNo restrictions

21. How to make a clickable text to another page ?

Use Anchor tag

OUTPUT : HTML Interview questions and answers for freshers

22. What role does  CSS (Cascade Style Sheet ) play ?

This image explains the best
why use css in html , html interview questions pdf , html interview questions and answers for freshers

22.5 How to use CSS Selectors ?

PS: It’s is a CSS Question but you should have some knowledge of it :p

We can use Element selector , Class Selector and Grouping selectors

Element selector : It uses HTML Id element , we must first set Id of an element in in order to apply CSS on it , ” # “(#ID) is used to add styling to that particular element.

Class Selector : If an element is given any class in html , styling can be added to it by using ” . ”

Group Selector : We apply styling to a whole group for example to all the h1 s , so all the h1 elements will get specified styling .

Hope these Interview Questions help you crack the interview , Don’t forget to  Subscribe   if you liked our content !!

Download this HTML Interview Questions list Pdf by clicking the PDF icon above the post .

One Response to “Top 22.5 HTML Interview questions and answers for freshers pdf

Leave a Reply

Your email address will not be published. Required fields are marked *