HTML Docs
HTML Docs
Here are the HT ML interview questions most likely to be asked during the interviews.
This list also covers some HTML CSS interview questions to help you start or move
ahead in your web development or HTML career. Here we have gathered both the
basic and advanced HTML Interview questions for freshers and experienced-level
candidates.
Here is the list of the most important basic HTML interview questions for freshers:
It is a markup language that provides f lexibility to design web pages with text.
Disclaim e r:
o n 0 1-No v-20 23.
It is easy to use and learn.
It enables programmers to add images, video, and audio to a web page to make it more
interactive.
HT ML allows programmers to add a link on web pages, helping the readers to browse
the inf ormation of their interest.
Q3. What is t he dif f erence bet ween HTML element s and t ags?
HT ML Elements T ags
Ans. No, all HT ML tags do not have an end tag. For example, the <br> tag is used to break
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
the line, and <image> tag is used to insert an image into a document. T hey are considered
self -closing tags and do not require an end tag.
If you are a beginner and want to learn HTML or a professional who wants to upskill to get
ahead in your career, check out the popular HTML courses here.
Q5. Which HTML t ags are used while displaying t he dat a in t he t abular f orm?
Ans. T he f ollowing HT ML tags are used to display the data in tabular f orm:
<html>
<head>
</head>
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
</html>
Q7. What is HTML5? What are some of it s new f eat ures t hat were not present
in HTML?
Ans. HT ML5 is the latest version of the Hypertext Markup Language. Some of the new
f eatures of HT ML5 are:
HT ML5 supports SVG, canvas, and other virtual vector graphics. In HT ML, vector
graphics can only be used with Flash, VML (Vector Markup Language), or Silverlight.
HT ML5 allows JavaScript to run within a web browser. T he previous version allowed
JavaScript to run in the browser interf ace thread.
HT ML5 is not based on SGML. It comes with enhanced parsing rules f or improved
compatibility.
In HT ML5, web SQL databases are used to store data temporarily. Previously, only the
browser cache was used.
Some elements have been removed – applet, isindex, nof rames, acronym, dir, f ont,
f rame, f rameset, and big are removed.
New elements have been added – time, summary, aside, audio, command, and data.
Q8. What are t he most commonly used list s used while designing a page?
Ans. T he f ollowing are the most commonly used lists that are used while designing a page:
def inition list (<dl>, <dt> and <dd> tags) – displays elements in def inition f orm like in a
dictionary.
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
Ans. HT ML attributes provide additional inf ormation about HT ML elements. T hey are def ined
directly af ter the tag name. T hey only appear in opening tags and not in closing tags.
Some commonly used HT ML attributes include src Attribute, alt Attribute, id Attribute, and
href Attribute.
Ans. Semantic HT ML is a coding style. It uses HT ML markup to reinf orce the semantics or
meaning of the content in webpages and web applications rather than just def ining its look
or appearance. It introduces meaning to the code we write.
For example: <f orm>, <table>, and <article>, these tags clearly def ine its content.
Ans. T he HT ML <article> Element specif ies independent and self -contained content in a
document, page, application, or site which is independently distributable or reusable. Since it
is independent of the document or website, it can be viewed, reused, and distributed
separately.
Forum post
Blog post
Newspaper article
Ans. HT ML layout represents how all the elements in the document are arranged. It is a vital
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
part of basic page design and is important f or creating a website to appear prof essional and
attractive. Every website has a specif ic layout to display content in a specif ic manner. T he
f ollowing HT ML elements are used to def ine the dif f erent parts of a webpage:
Q13. What is t he dif f erence bet ween a block-level element and an inline
element ?
Ans. T he dif f erences between block-level elements and inline elements are:
Ans. Images can be inserted using an HT ML page’s <img> tags . It is an empty tag with
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
only attributes and does not require a closing tag. T he <img> tag must be used inside
<body>…</body> tag. T he f ollowing parameters will be required to insert an image using
<img> tag
src attribute – It is used to add the path to the image (URL of the image).
Example:
Copy code
<!DOCTYPE html>
<ht ml>
<head>
…
</head>
<body>
…
<img src=”URL” alt =”add_alt t ext ” widt h=”widt h” height =”height ”>
…
</body>
</ht ml>
Ans. HT ML content is aligned on a page using the CSS text-align property. It sets the
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
horizontal alignment of the content inside a block element or table-cell box. T he text-align
property works like a vertical-align but in the horizontal direction. It works on text and
all other content inside the block element, such as images and buttons.
Copy code
<!DOCTYPE html>
<ht ml>
<head></head>
<body>
<h1>Heading</h1>
<p st yle="t ext -align:cent er/lef t /right /just if y;">t ext </p>
</body>
</ht ml>
Check out the Top Web Development Courses to Start a Career as a Web Developer
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
Copy code
Ans. The <b> </b> tag or <strong> </strong> tag are used to bold text in HTML.
The following are the commonly asked advanced-level HTML interview questions:
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
INPUT
DESCRIPT ION HT ML MARKUP
T YPE
<input
datetime-
T o select the date and time as per the local time type=”datetime-
local
local”>
week Enables you to select the week and year <input type=”week”>
email Validates the input using the standard email f ormat <input type=”email”>
<input
search Searches a data set
type=”search”>
<input
number Accepts only numbers
type=”number”>
Ans. Marquee tag is a non-standard HT ML element that causes text to scroll up, down, lef t,
or right automatically. You can put the text which you want to scroll on a web page within the
f ollowing tag:
<marquee>……</marquee>
Q22. What happens if you open t he ext ernal CSS f ile in a browser?
Ans. If you try to open the external CSS f ile in a browser, the browser will not open the f ile.
T his is because the f ile has a dif f erent extension. T he only way to use an external CSS f ile
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
is to ref erence it using the <link/> tag within another HT ML document.
<br> – to separate the line of text. It breaks the current line and conveys the f low to the
next line
Ans. T he <if rame> tag specif ies an inline f rame. It is used to display a web page within a web
page (to embed another document within the current HT ML document).
For example – T he src attribute is used to specif y the URL of the document that occupies
the if rame.
Syntax:
Here’s the list of Top Universities Offering Free Online Programming Courses
Q25. What is t he dif f erence bet ween LocalSt orage and SessionSt orage
Object s?
1. It stores the data without an expiry date. 1. Stores the data f or only one session.
2. T he data can be shared between multiple 2. Data is accessible only in the current
windows of the browser. window of the browser.
3. Data is not deleted when the browser 3. T he data is deleted if the browser
window closes. window closes.
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
Q26. What are t he dif f erent media t ypes and f ormat s support ed by HTML?
Ans. HT ML supports a variety of media f ormats f or sound, music, videos, movies, and
animations. T he dif f erent f ormats supported by HT ML are:
Video: MPEG, AVI, QuickT ime, RealVideo, WMV, Flash, WebM, and MP4
Ans. An image map is defined by the <map> tag. Using this the image map tag, we
can linking the different web pages using a single image. We can add one or more
clickable areas in a single image using <area> tags.
Ans. We can use <font color =”color”> </font> to create multi-colored text on a web
page for the specific texts that you want to color.
Ans. Below is the code to add a f avicon. Access the code of your webpage and in the
<HEAD> section add the f ollowing code.
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
HT ML XHT ML
Not necessary to close the tags in the It is necessary to close the tags in the order
order they are opened. they are opened.
It requires a lenient HT ML-specif ic parser. Parsing is done with a standard XML parser.
Ans. URL Encoding is the process of encoding non-ASCII characters in URLs to a f ormat
that is universally accepted by web browsers. URLs are sent over the Internet using the ASCII
character set. If a URL contains characters outside the ASCII set, the URL has to be
converted.
Looking for one single place to learn and grow in your career? Here’s the list of Top Online IT
Courses for freshers and experienced professionals.
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
Ans. An empty element is an HTML element that has no content. Example <br>
Ans. T his is one of the commonly asked HTML CSS interview questions.
Inline CSS is used f or styling small contexts. It contains the CSS property in the body section
attached to the element. The style attribute is used in the relevant tag to use inline
styles added.
Example:
Copy code
<!DOCTYPE html>
<ht ml>
<body st yle="background-color:whit e;">
<h1 st yle="color:red;">A Red Heading</h1>
<p st yle="color:blue;">A blue paragraph.</p>
</body>
</ht ml>
It requires you to add <style> tag in the <head> section of the HT ML document. It is most
suited f or styling a single page that has a unique style. However, using this style f or multiple
pages is time-consuming as CSS rules need to be added to every page of the website.
Example:
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
Copy code
<head>
<st yle>
body {
background-color: black;
}
h1 {
color: red;
padding: 50px;
}
</st yle>
</head>
It is used when the style is applied to many pages. T o use an external CSS, add a link to it in
the <head> section of each HT ML page.
Example:
Copy code
<head>
<link rel="st ylesheet " t ype="t ext /css" href ="myst yle.css" />
</head>
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
Ans. T he <f igure> tag identif ies self -contained content related to the main content. It adds
self -contained content like photos, diagrams, illustrations, etc. T he f igure, its caption, and
its contents are ref erenced as a single unit f rom the main f low of the document. T he
<f igure> tag has two elements img src and f igcaption. Img src is used f or adding image
sources in a document, while f igcaption sets the caption of an image.
Example:
Copy code
<f igure>
<img src="pancakes.jpg" alt ="Blueberry Pancakes">
<f igcapt ion>A St ack of Blueberry Pancakes</f igcapt ion>
</f igure>
Ans. T he <datalist> tag provides autocomplete f eature in the HT ML f iles. It enables users to
add the autocomplete f orm based on the predef ined options. It can be used with an input tag
so users can easily f ill the data in the f orms using predef ined options.
Example: If you press A, it will show a list of cars starting with A letter.
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
Copy code
Ans. A Group of characters that represent reserved and invisible characters in HT ML are
known as HT ML entities. T hese strings start with an ampersand(&) symbol and end with a
semicolon(;). T hey can also replace some characters that are challenging to type on a
standard keyboard.
Few entity symbols and their number are mentioned in below table:
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
Q37. What is t he dif f erence bet ween cell padding and cell spacing?
Ans.
cell padding is the white space that exists T he space that exists between specif ic
between the edge of a table cell and its neighboring cells is known as “cell
contents. spacing.”
inline: Any element at the block level can be shown as an inline element using this
technique. Aspect values f or the element’s height and width have no bearing.
inline-block: T his property is identical to inline, however utilizing the display as inline-block,
allows us to f ormat the element by using its height and width values.
f lex: T he element and container are shown as f lexible construction. It adheres to f lexbox
properties.
inline-f lex: While its content adheres to the f lexbox specif ications, the f lex container is
shown as an inline element.
Q39. What is t he dif f erence bet ween display: none and visibilit y: hidden?
Ans. When an HT ML element has the property “visibility: hidden,” it will be hidden f rom the
webpage yet still occupy space. However, if we apply the “display: none” property f or an
HT ML element, the element will be hidden and will not occupy any space on the website.
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
Also Read: HT ML Formatting: HT ML T ags f or T ext Formatting
Ans. Using a scripting language such as JavaScript, the “canvas” element serves as a
container f or drawing visuals on web pages. It enables the rendering of bitmap pictures and
2D shapes in a dynamic and scriptable manner. In canvas, there are numerous ways to draw
pathways, boxes, circles, text, and add images.
Example:
Output:
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
Also Read: How to create HT ML Forms
Ans. No, the HT ML 5 tags won’t work properly and the browser won’t be able to tell that it’s
an HT ML document.
Ans. T his attribute is mainly used f or f orm validation. Bef ore submitting the f orm, it compels
the user to enter text in the text area or text f ield.
Q43. What is t he dif f erence bet ween <em>, <i> and <st rong>, <b> t ags?
Ans. T he ef f ects of the tags <strong>, <b> and <em>, <i> on a typical webpage are identical.
Italic and bold are indicated by the tags <b> and <i>. T hese two tags do little more than apply
f ont styles, while the bold tag (<b>) simply adds extra ink to the text.
While the <strong> and <em> tags indicate that a section of text is more important than
other material in both terms of importance and emphatic stress. T hese tags’ meanings are
semantic.
Q44. What is t he dif f erence bet ween <div> and <span> t ag?
Ans. T he dif f erence between the span and div elements is that the span element is in-line
and typically used f or a brief paragraph or another tiny block of HT ML inside a line. A div or
division element, on the other hand, is a block line, which is comparable to having a line break
bef ore and af ter it and is used to combine larger portions of code.
Q1. If t here isn’t any t ext in bet ween t he HTML t ags, what will happen?
Ans. If no text is present in between the tags, there would be nothing to f ormat. As a result,
nothing will show up on the screen. Some tags, such as those that don’t have a closing tag,
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
like the <img> tag, don’t need any text in between them.
Q2. How can you t ell what charact er set an HTML5 document is using? What
dist inguishes t his f rom earlier HTML st andards?
Ans. In HT ML5, the charset attribute of a <meta> tag inside the document’s <head> element
can be used to specif y the encoding being utilized.
Since the charset attribute wasn’t present in earlier HT ML standards, this syntax is a little bit
simpler. T he f ollowing is an example of how the <meta> element would be used in an HT ML
4.01 document:
Ans: One of the best HT ML5 APIs is Geolocation API which is used to determine the
geographical location of the user f or a web application. With HT ML5, you can now browse to
the visitor’s current website’s latitude and longitude coordinates. T hese coordinates can be
recorded by JavaScript and sent to the server, allowing it to display your position on the
page. T he geolocation API is used with navigation.geolocation object. A Geolocation object
that contains the user’s location inf ormation and can produce a customized result is
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
returned via the read-only property of the object.
Syntax:
Ans. White space is a term used to describe empty or blank values in the code the browser
reads and displays. T he collapsing of these white spaces is a unique characteristic of HT ML.
T he advantage of this f eature is in its ability to reduce the time of transmitting data between
server and client by removing unused bytes taken up by the white spaces. If you accidentally
leave excess white space, the browser will disregard it and perf ectly display the UI.
Example:
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
Output:
Ans. T he text is automatically wrapped to f it the browser window by def ault. T he text might,
however, go outside the browser window if it is a component of a table cell with a f ixed
width.
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
Q4. In t erms of st yle sheet s, what is t he hierarchy t hat is being used?
Ans. T he style def inition that is closest to the actual tag takes precedence when a single
selector has three separate style def initions. External style sheets have a lower priority than
embedded style sheets, which have a lower priority than the inline style.
Q5. Compare and cont rast an HTML specif icat ion wit h a browser’s
implement at ion.
Due to this, despite the enhanced specif ications, cross-browser support still causes
developers problems. Additionally, while HT ML5 specif ies certain guidelines f or invalid
documents (those with syntactical f aults), f aulty documents may contain anything, making it
hard f or the specif ication to f ully address every scenario. T hus, the browser is lef t in charge
of making numerous decisions regarding how to handle damaged documents.
Q6. Can element s f rom art icles be f ound in sect ions? Can a sect ion element
be f ound in an art icle? Give usage illust rat ions.
Ans. T he answer to both queries is “yes,” meaning that both “section” and “article” elements
can be f ound in both a section and an article.
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
On the other hand, an article can have a section at the end f or reader f eedback.
Example:
Output:
Q8. What is t he dif f erence bet ween met er and progress t ag?
Ans. T he meter tag measures data within a specif ied range, whereas the progress tag just
represents the task’s progress.
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
Q1. How can websit e asset s be opt imized?
File compression
File concatenation
CDN Hosting
Of f loading assets
Re-organizing
Ans. T he management of data transf ers f rom one user to another within a domain is
handled by the Data T ransf er API. For example, this transf er can be used to redistribute
application data belonging to a user who has left the company. You must first define a
transfer before starting it with the insert method to use the Data Transfer API. The
transfer can include application-specific parameters and describes one or more apps
whose data will be transmitted.
Create a transf er resource that lists the users at the source and destination and the
programs to which the data will be sent.
Read Also: Dif f erence between HT ML and XML: Which one to use?
Q3. What does HTML5’s applicat ion cache do, and why is it necessary?
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
Q4. What does an HTML5 web worker do?
Ans. A script that executes in the background on a dif f erent thread f rom the main web page
is known as a “web worker” in HT ML5. Long tasks can be completed with the help of web
workers without slowing down the website. Web workers cannot access the f ollowing
JavaScript objects because web workers reside in external f iles:
T he window object
T he document object
T he parent object
Ans. Metadata in HTML5 can be specified using the “head” element of an HTML
document. The “head” element contains information about the document, such as
its title, author, description, and keywords.
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
Copy code
<!DOCTYPE html>
<ht ml>
<head>
<t it le>My Websit e</t it le>
<met a name="descript ion" cont ent ="T his is my personal websit e.">
<met a name="aut hor" cont ent ="John Doe">
<met a name="keywords" cont ent ="websit e, personal, blog">
</head>
<body>
<!-- The content of the website goes here -->
</body>
</ht ml>
Ans. A standardized method of adding extra semantics to your web pages is by using
microdata.
You can def ine your unique elements using microdata and add unique attributes to your web
pages. Microdata is a general term f or a collection of name-value pairs.
Each name-value pair in the groups is ref erred to as a property. Regular elements are used
to represent objects and properties.
Q7. What is t he dif f erence bet ween SVG and Canvas HTML5 element s?
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
SVG Canvas
Ideal f or static and interactive graphics Ideal f or complex animations and games
Can be scaled without losing quality Scaling can lead to loss of quality
Ans. Custom attributes are those that are specif ically designed and are not included in the
standard HT ML5 attributes. T hey enable us to customize HT ML tags by adding our own data.
T hese can be used with any HT ML element because they are not specialized. Custom
attributes allow storing additional data that is not required for a specif ic purpose.
T his inf ormation is kept within the program or website. T he term “data attributes” also
applies to the custom attributes. A custom attribute is one whose name begins with the
pref ix data-. Custom attributes can be included using the data-* attributes on any HT ML
element. T he user agent ignores these entirely. T he page’s JavaScript can make use of the
stored data. Additionally, we may style our elements using these data attributes.
Syntax:
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.
Q9. What are t he essent ial goals of t he HTML5 specif icat ion?
Ans. The HTML5 specification was designed to achieve several significant goals,
including:
Multimedia Support: Provide native support for multimedia content such as video
and audio, eliminating the need for third-party plugins like Adobe Flash.
Semantic Markup: Promote semantic markup to make web content more meaningful
and understandable by humans and machines.
Security: Improve security by providing more robust mechanisms for handling user
input and data and preventing malicious code from executing on a user’s device.
Q10. What is t he use of t he <out put > t ag in HTML, and what are it s at t ribut es?
Ans. T he HT ML <output> tag is used to represent a result f or any calculation. Its attributes
are mentioned below:
f or: It outlines the connection between the calculation’s inputs and outputs.
f orm: T his specif ies the f orm to which the output element belongs.
name: An <output> element’s name is specif ied via the name attribute.
Example:
Disclaim e r: This PDF is auto -generated based o n the info rmatio n available o n Shiksha as
o n 0 1-No v-20 23.