NOTES
70+ HTML Interview Q&A
1. What is HTML?
--> HTML stands for HyperText Markup Language. It is used to design
web pages using a markup language. HTML is a combination of Hypertext
and Markup language. Hypertext defines the link between the web pages.
The markup language is used to define the text document within the tag
which defines the structure of web pages. HTML is used to structure the
website and is therefore used for Web Development.
2. Difference between HTML and XHTML ?
S.No HTML XHTML
HTML stands for Hypertext XHTML stands for Extensible
1
Markup Language. Hypertext Markup Language.
It was developed by W3C
It was developed by Tim
2 i.e.lowercase World Wide Web
Berners-Lee.
Consortium.
3 It was developed in 1991. It was released in 2000.
The format is a document
4 The format is a markup language.
file format.
The used filename The used Filename extensions
5
extensions are .html, .htm. are .xhtml, .xht, .xml.
code_wars_official
NOTES
3. What are the various markup languages available ?
HTML: Hypertext Markup Language
KML: Key whole Markup Language
MathML: Mathematical Markup Language
SGML: Standard Generalized Markup Language
XHTML: eXtensible Hypertext Markup Language
XML: eXtensible Markup Language
4. What is the current version of HTML?
--> HTML 5 is the fifth and current version of HTML.
5. What is !DOCTYPE?
--> A doctype or document-type declaration is an instruction that tells
the web browser about the markup language in which the current page is
written. The doctype is not an element or tag, it lets the browser know
about the version of or standard of HTML or any other markup language
that is being used in the document. The DOCTYPE for HTML5 is case-
insensitive and can be written as shown below:
<!DOCTYPE html>
6. How to comment in HTML?
--> Normally HTML comments are not being displayed in the browser.
But these comments can help to document the HTML source code.
<!– Write your comments here –>
code_wars_official
NOTES
7. What are elements and tags, and what are the differences
between them ?
HTML Tags: Tags are the starting and ending parts of an HTML element.
They begin with < symbol and end with > symbol. Whatever is written
inside < and > are called tags. Ex: <b></b>
HTML elements: Elements enclose the contents in between the tags.
They consist of some kind of structure or expression. It generally
consists of a start tag, content, and an end tag. Ex: <b> Hello </b>
8. What are the various heading tags and their importance?
--> There are 6 levels of headings defined by HTML. These six heading
elements are H1, H2, H3, H4, H5, and H6; with H1 being at the highest
level and H6 at the least.
Importance of Heading:
Search Engines use headings for indexing the structure and content
of the webpage.
Headings are used for highlighting important topics.
They provide valuable information and tell us about the structure of
the document.
9. How to give space in HTML?
--> In order to add a space in the webpage, Go where you want to add the
space and then use the spacebar. Normally, HTML displays one space
between words, no matter how many times you have entered the space
bar.
--> Now if you Type to force an extra space.
code_wars_official
NOTES
10. How to redirect to a particular section of a page using
HTML?
--> One can use the anchor tag to redirect to a particular section on the
same page. You need to add “id attribute” to the section that you want
to show and use the same id in href attribute with “#” in the anchor tag.
So that On click a particular link, you will be redirected to the section
that has the same id mentioned in the anchor tag.
Syntax:
<a href="#home_section">home</a>
<section id="home_section">
Information About Page
</section>
11. What are the different formats in which colors in HTML can
be declared?
--> The color of an element can be defined in the following ways:
Built-In Color
RGB Format
RGBA Format
Hexadecimal Notation
HSL
HSLA
Hue: Hue is the degree of the color wheel. Its value lies between 0 to
360 where 0 represents red, 120 represents green and 240
represents blue color.
code_wars_official
NOTES
12. How to create a link in HTML?
--> A Link is a connection from one Web resource to another. A link has
two ends, An anchor and a direction. The link starts at the “source”
anchor and points to the “destination” anchor, which may be any Web
resource such as an image, a video clip, a sound bite, a program, an
HTML document, or an element within an HTML document.
Syntax:
<a href="url">Link Text</a>
Explanation:
href: The href attribute is used to specify the destination
address of the link used.
Text link: The text link is the visible part of the link.
13. What are attributes?
--> An attribute is used to provide extra or additional information about
an element.
All HTML elements can have attributes. Attributes provide additional
information about an element.
It takes 2 parameters ie., name and value. These define the properties
of the element and are placed inside the opening tag of the element.
The name parameter takes the name of the property we would like to
assign to the element and the value takes the property value or
extent of the property names that can be aligned over the element.
Every name has some value that must be written within quotes.
code_wars_official
NOTES
14. Are <b> and <strong> tags same? If not, then why?
HTML strong tag: The strong tag is one of the elements of HTML used in
formatting HTML texts. It is used to show the importance of the text by
making it bold or highlighting it semantically.
Syntax:
<strong> Contents... </strong>
HTML strong tag: The strong tag is one of the elements of HTML used in
formatting HTML texts. It is used to show the importance of the text by
making it bold or highlighting it semantically.
Syntax:
<b> Contents... </b>
The main difference between the <bold> tag & <strong> tag is that the
strong tag semantically emphasizes the important word or section of
words while the bold tag is just offset text conventionally styled in bold
15. What are HTML entities?
--> ‘<‘ is already reserved in HTML language. Sometimes this character
needs to display on the web page which creates ambiguity in the code.
Along with these are the characteristics which are normally not present
in basic keyboard ( £, ¥, €, © ), etc. HTML provides some Entity names
and Entity numbers to use these symbols. Entity number is easy to learn.
code_wars_official
NOTES
16. How can we add symbols in HTML?
There are some characters in HTML that are reserved, & have special
meaning when they are used in an HTML document. Like if you used less
than or greater than sign in your HTML document then the browser will
treat them differently. So we will use HTML entities to insert symbols in
a webpage.
Special Symbols Syntax
©:copyright ©
®:registered trademark ®
™:trade mark ™
℅: care of ℅
¶: paragraph ¶
17. What is the difference between the POST method and the
GET method?
--> The Hypertext Transfer Protocol (HTTP) is designed to enable
communications between clients and servers. HTTP works as a request-
response protocol between a client and server. There are 2 HTTP request
methods ie., GET & POST
GET: It requests data from a specified resource.
POST: This method is used to submit data to be processed to a
specified resource.
.
code_wars_official
NOTES
18. What is HTML Canvas?
The HTML “canvas” element is used to draw graphics via JavaScript.The
“canvas” element is only a container for graphics. One must use
JavaScript to actually draw the graphics. Canvas has several methods
for drawing paths, boxes, circles, text, and adding images.
<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas"
width="400"
height="200"
style="border:2px solid #000000;">
</canvas>
</body>
</html>
19. What is SVG?
--> SVG stands for Scalable Vector Graphics. It basically defines vector-
based graphics in XML format. SVG graphics do NOT lose any quality if
they are zoomed or resized. Every element and every attribute in SVG
files can be animated.
Advantages of SVG: Advantages of using SVG over other image formats
(like JPEG and GIF) are:
SVG images can be created and edited with any text editor.
SVG images can be searched, indexed, scripted, and compressed.
SVG images are scalable.
SVG images can be printed with high quality at any resolution.
.
code_wars_official
NOTES
20. What are the different multimedia formats supported by
HTML?
--> Multimedia files have formats and different extensions like .wav,
.mp3, .mp4, .mpg, .wmv, and .avi
21. What is HTML Web Storage API?
--> SessionStorage and LocalStorage are known as the web storage API.
Data can be stored on the client-side by using these APIs.
SessionStorage:
SessionStorage is used for storing data on the client-side.
The maximum limit of data saving in SessionStorage is about 5 MB.
Data in the SessionStorage exist till the current tab is open if we
close the current tab then our data will also erase automatically from
the SessionStorage.
Like SessionStorage, LocalStorage is also used for storing the data on
the client-side.
The maximum limit of data saving is about 5 MB in LocalStorage also.
LocalStorage has no expiration time, Data in the LocalStorage persist
till the user manually deletes it. This is the only difference between
LocalStorage and SessionStorage
.
22. What are void elements?
--> The elements that only have start tags and do not contain any
content within it, these elements are called Void Elements. It can
only have attributes but does not contain any kind of content.
Example of such elements are <br>, <hr>, <img>, <input>, <link>,
<base>, <meta>, <param>, <area>, <embed>, <col>, <track>, <source>
etc.
code_wars_official
NOTES
23. What tags are used to separate a section of text?
<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.
24. In how many ways you can apply CSS to your HTML file?
There are 3 ways in which we can add CSS to our HTML file, they are
given below:
Inline CSS: Inline CSS contains the CSS property in the body section
attached with the element known as inline CSS. This kind of style is
specified within an HTML tag using the style attribute.
Internal or Embedded CSS: This can be used when a single HTML
document must be styled uniquely. The CSS ruleset should be within
the HTML file in the head section i.e the CSS is embedded within the
HTML file.
External CSS: External CSS contains a separate CSS file that contains
only style property with the help of tag attributes (For example class,
id, heading, … etc). CSS property is written in a separate file with a
.css extension and should be linked to the HTML document using the
link tag. This means that for each element, style can be set only once
and that will be applied across web page
.
code_wars_official
NOTES
25. What is the difference between <html lang=”en’> and <html
lang=”en-US’>?
The lang attribute specifies which language is used to write the content
of a web page. It is used to set the language for the whole text of the
web page.
The difference between <html lang=”en’> and <html lang=”en-US’> is
described below:
<html lang=”en’>: The <html lang=”en’> only specifies the language code
of the page meaning en or English is used for all the text on the page.
<html lang=”en-US’>: The <html lang=”en-US’> specifies the language
code of the page followed by the country code which means the US
style of English language is used for all the text on the page.
<html lang=”en-GB’> which means the United Kingdom style
of English
<html lang=”en-IN’> which means the Indian style of
English
26. Explain Web Worker in HTML.
Web workers are multithreaded object which is used to execute
Javascripts in the background without affecting the performance of the
application or webpage. Web Workers allow for long-running scripts that
are not interrupted by scripts that respond to clicks or other user
interactions and allow long tasks to be executed without affecting the
responsiveness of the web page. Generally, it is used for big CPU-
intensive tasks.
code_wars_official
NOTES
27. How to open a hyperlink in another window or tab in HTML?
There are several different ways to open a hyperlink in another window
or tab such as using JavaScript, jQuery, or HTML. In order to open a
hyperlink in another window or tab, use the target attribute and provide
it value _blank in the anchor tab.
<element target="_blank|_self|_parent|_top|framename"\>
Attribute Values:
_blank: It opens the link in a new window.
_self: It opens the linked document in the same frame.
_parent: It opens the linked document in the parent frameset.
_top: It opens the linked document in the full body of the window.
framename: It opens the linked document in the named frame.
28. Define multipart form data.
Multipart Form Data: The ENCTYPE attribute of the <form> tag specifies
the method of encoding for the form data. It is one of the two ways of
encoding the HTML form. It is specifically used when file uploading is
required in HTML form. It sends the form data to the server in multiple
parts because of the large size of the file.
<form action="login.php" method="post"
enctype="multipart/form-data">
</form>
code_wars_official
NOTES
29. How to create scrolling text or images on a webpage?
This task can be achieved through <marquee> tag in HTML that helps to
create scrolling text or image on a webpage. It scrolls either from
horizontally left to right or right to left, or vertically from top to bottom
or bottom to top.
<marquee>
<--- contents --->
</marquee>
30. What are the media element tags introduced by HTML5?
HTML5 introduced 5 most popular media element tags that are
supported by the browsers, which are described below:
<audio>: It is an inline element that is used to embed sound files into
a web page.
<video>: It is used to embed video files into a web page.
<source>: It is used to attach multimedia files like audio, video, and
pictures.
<embed>: It is used for embedding external applications which are
generally multimedia content like audio or video into an HTML
document.
<track>: It specifies text tracks for media components audio and
video.
code_wars_official
NOTES
31. How to insert an image in HTML?
--> <img> tag is used to add an image in a web page.
--> Images are not inserted into a web page basically they are
linked to web pages.
<img> tag has two required parameters:
src – The path to the image
alt – An alternate text for the image
<img src="image path" alt="This is an image">
<img src="demo.jpg" alt="This is an image">
32. How to align text in HTML?
Basically, if you want to align your text using HTML, then you
need to use css and follow the proper process:
.diva{
text-align: center;
}
.divb {
text-align: left;
}
.divc {
text-align: right;
}
.divd {
text-align: justify;
}
code_wars_official
NOTES
33. What is dom in HTML?
--> DOM stands for Document Object Model. When a web page
is getting loaded that time the browser creates a Document
Object Model of the page and it is constructed as a tree of
Objects. HTML DOM is basically an Object Model for HTML.
HTML DOM describes:
The HTML elements as objects
Properties of all HTML elements
Methods of all HTML elements
Events of all HTML elements
34. How to run HTML program?
1. Step 1: Open Notepad (PC) Windows 8 or later: …
2. Step 2: Open TextEdit (Mac) Open Finder > Applications >
TextEdit.
3. Step 3 Write Some HTML. Write or copy the following HTML
code into Notepad:
4. Step 4: Save the HTML Page. Save the file on your computer.
…
5. Step 5: View the HTML Page in Your Browser
code_wars_official
NOTES
35. How to save HTML file?
In order to save html file
On the main menu
click File > Save As
Right-click within the HTML document
click File > Save As
In the Save As dialog box, specify the file name and location,
then click Save
36. How to add favicon in HTML?
You can create a .png image and then use f the following
snippets between the <head> tags for the static HTML
documents:
<link rel="icon" type="image/png"
href="/favicon.png"/>
<link rel="icon" type="image/png">
37. What are Inline and block elements in HTML?
Some examples of block elements are <div>, <p>, <header>,
<footer>, <h1>…<h6>, <form>, <table>, <canvas>, <video>,
<blockquote>, <pre>, <ul>, <ol>, <figcaption>, <figure>, <hr>,
<article>, <section>, etc. Some examples of inline elements are
<span>, <a>, <strong>, <img>, <button>, <em>, <select>, <abbr>,
<label>, <sub>, <cite>, <abbr>, <script>, <label>, <i>, <input>,
<output>, <q>, etc.
code_wars_official
NOTES
38. Is audio tag supported in HTML 5?
Audio tags are supported in HTML5 and with these, you can add
audio to a webpage. The file formats supported by HTML5
include MP3, WAV, and OGG.
39. What is the advantage of collapsing white space?
White spaces are a sequence of blank space characters, treated
as a single space character in an HTML document.
The advantages of collapsing white space are
Helps the content of the code to be more understandable
and readable to the users.
Decreases the transmission time between the server and
the client and removes unnecessary bytes that are occupied
by the white spaces.
If you leave extra white space by mistake, the browser will
ignore it and display the content properly.
40. In how many ways can we position an HTML element?
To position an HTML element there are five different values:
static.
relative.
fixed.
absolute.
sticky.
code_wars_official
Click Here for More Questions
👇
More Question
References :-
W3 School <-- Click Here
My Greate Learning <-- Click Here
Thank You 💙