HTMLNDHTML Interview Questions
HTMLNDHTML Interview Questions
HTML stands for Hyper Text Markup Language. It is a language of the World Wide
Web. It is a standard text formatting language which is used to create and display
pages on the Web. HTML makes the text more interactive and dynamic. It can turn
text into images, tables, links. HTML pages are saved by adding .html or .html in
web page name.
Elements Tags
The element is an individual component of the HTML It is the root of the HTML document wh
web page or document. It represents semantics or specify that the document is HTML. For
meaning. For example, the title element represents Head tag is used to contain all the hea
the title of the document. the HTML file.
Q3. What are Attributes and how do you use them?
Each tag has additional attributes that change the way the tag behaves or is
displayed. For example, a <input> tag has a type attribute, which you can use to
specify whether it’s a text field, checkbox, radio button or one of many more
options.
Attributes are specified directly after the name of the tag, inside the two angled
brackets. They should only ever appear in opening tags or in self-closing tags. But,
they can never be in closing tags.
Example:
Block Inline
A block-level element is drawn as a block that Inline elements are drawn where they a
stretches to fill the full width available to it i.e, the and only take up space that is absolutel
width of its container and will always start on a new The easiest way to understand how the
line. look at how text flows on a page.
Elements that are block-level by default: <div>, Examples of elements that are inline by
<img>, <section>, <form>, <nav>. default: <span>, <b>, <strong>, <a>, <i
Q5. When are comments used in HTML?
To understand the code easily, you can add code comments to your HTML
document. These are not displayed in the browser, but they help you in leaving
notes for yourself and other developers as to what a section of HTML is for. The
start of the comment is denoted by <!– and the end is marked by — >. Anything in
the middle will be completely ignored, even if it contains valid HTML.
For example:
The list of HTML tags used to display data in the tabular form include:
Tag Decsription
<table> It defines a table
<tr> This tag defines a row in a table
<th> It defines a header cell in a table
<td> This is used to define a cell in a table
<caption> It defines the table caption
<colgroup> It specifies a group of one or more columns in a table for forma
<col> This is used with <colgroup> element to specify column properties for e
<tbody> This tag is used to group the body content in a table.
<thead> It is used to group the header content in a table
<tfooter> It is used to group the footer content in a table
Q7. How to create a Hyperlink in HTML?
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:
There are many common lists used for design a page. You can choose any or a
combination of the following list types:
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 <b>
</b> tag is not used for bold statement as well as <i> </i> tag is used for italic.
Instead of these we use <strong></strong> and <em></em> tags.
The HTML iframe tag is used to display a nested webpage. In other words, it
represents a webpage within a webpage. The HTML <iframe> tag defines an inline
frame. For example:
1
<!DOCTYPE html>
2<html>
3<body>
4<h2>HTML example</h2>
5Use the height and width attributes to specify the size of the iframe:
6<iframe src="<a href="https://www.edureka.co/">https://www.edureka.co/</a>" height="300" width
7</body>
8</html>
Q11. What is an image map?
An image map is used for linking many different web pages using a single image.
It is represented by <map> tag. You can define shapes in images that you want to
include as part of an image mapping.
Syntax:
HTML layout specifies a way in which the web page is arranged. Every website has
a specific layout to display content in a specific manner. Following are
different HTML elements which are used to define the different parts of a
webpage:
• <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 – This 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.
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 or division element is block-line which is equivalent to having a line-break
before and after it and used to group larger chunks of code.
Example:
1<div id="HTML">
2This is <span class="Web Dev">interview</span>
3</div>
Q18. What is the purpose of using alternative texts in images?
The 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.
You can create new elements for the document in the following way:
1<script>
2document.createElement﴾"myElement"﴿
3</script>
It can be also be used in the HTML as:
1<myElement>hello edureka!</myElement>
Q20. Is the <!DOCTYPE html> tag considered as a HTML tag?
There are many type of HTML, such as, 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.
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.
Syntax:
1<iframe src="URL"></iframe>
Example:
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.
To make a picture a background image on a web page, you should put the
following tag code after the </head> tag.
Example:
1<span style="color:#ffffff;">
2In this page we use span.
3</span>
Q27. What is the advantage of collapsing white space?
By using indents, you can keep the list elements straight. If you indent each sub
nested list in further than the parent list, you can easily determine the various
lists and the elements that it contains.
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.
To insert a picture into the background image, you need to place a tag code after
the </head> tag in the following way:
Q32. What happens if you open the external CSS file in a browser?
When 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 <link/> tag within another HTML document.
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.
Q34. How do you create text on a webpage that allows you to send
an email when clicked?
To change the text into a clickable link to send an email, you need to use
the mailto command within the href tag. You can write it in the following way:
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. Whereas, 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.
The <br> tag is one way to separate the lines of text. There are other tags like the
<p> tag and <blockquote> tag that are also used to separate sections of text.
Q37. Are there instances where the 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.
Q38. Write an HTML table tag sequence that outputs the following:
50 pcs 100 500
10 pcs 5 50
1
2<table>
3<tr>
4<td>50 pcs</td>
<td>100</td>
5
<td>500</td>
6</tr>
7<tr>
8<td>10 pcs</td>
9<td>5</td>
10<td>50</td>
11</tr>
12</table>
Q39. What is the advantage of grouping several checkboxes
together?
The checkboxes don’t affect one another. But, grouping these checkboxes
together help to organize them. Checkbox buttons can have their name and do
not need to belong to a group. A single web page can have many different groups
of checkboxes.
Q40. What happens if there is no text between the tags? Does this
affect the display of the HTML file?
If there is no text present between the tags, there is nothing to format. Therefore,
no formatting will appear. Some tags, such as the tags without a closing tag like
the <img> tag, do not require any text between them.
The default size for a text field is around 13 characters. However, 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. Also, if the size attribute is set to
0, the size will be set to the default size of 13 characters.
Default cell borders, with a thickness of 1 pixel, are automatically added between
cells if the border attribute is set to a nonzero value. Similarly, If the border
attribute is not included, a default 1-pixel border appears when the rules attribute
is added to the <table> tag.
HTML SVG is used to describe the two-dimensional vector and vector or raster
graphics. SVG images and their behaviors are defined in XML text files. So as XML
files, you can create and edit an SVG image with the text editor. It is mostly used
for vector type diagrams like pie charts, 2-Dimensional graphs in an X, Y
coordinate system.
The button tag is used in HTML 5. It is used to create a clickable button within the
HTML form on the web page. This tag creates a “submit” or “reset” button. The
button tag code is as follows:
1<button name="button" type="button">Click Here</button>
Q45. List the media types and formats supported by HTML.
HTML supports a wide range of media formats for sound, music, videos, movies,
and animations. Some of the extensions supported by each media format are:
• 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
Cell Spacing is referred to as the space or gap between the two cells of the same
table. Whereas, Cell Padding is referred to as the gap or space between the
content of the cell and cell wall or cell border.
Example:
• Inline CSS: It is used for styling small contexts. To use inline styles add
the style attribute in the relevant tag.
• External Style Sheet: This is used when the style is applied to many
pages. Each page must link to the style sheet using the <link> tag. The
<link> tag goes inside the head section.
1<head>
2<link rel="stylesheet" type="text/css" href="mystyle.css" />
3</head>
1<head>
2<style type="text/css">
3hr {color:sienna}
4p {margin-left:20px}
5body {background-image:url("images/back40.gif")}
6</style>
7</head>
Q49. What are logical and physical tags in HTML?
Logical tags are used to tell the meaning of the enclosed text. The example of the
logical tag is <strong> </strong> tag. When we enclose the text in the strong tag,
it tells the browser that enclosed text is more important than other texts.
Physical tags are used to tell the browser how to display the text enclosed in the
physical tag. Some of the examples of physical tags are <b>, <big>, <i>.
Inline
Certain HTML elements allow you to execute a piece of JavaScript when a certain
event occurs. For example, a button allows you to run a script when you click on
it. These events are accessed through attributes and differ based on the events
that are available on each element. Here is an example that shows an alert with
a message when the user clicks on it:
1<script>
2 var x = 5;
3 var y = 6;
4 var result = x + y;
5 alert(“X + Y is equal to " + result);
6</script>
Link to a JavaScript file
It allows you to keep the content of the page separate to how users interact with
that content. Also, it allows you to load the same script on multiple pages. As
with the script block, you can load a JavaScript file from the <head> or <body>.
1<script src="my-code.js"></script>
With this, we have come to the end of HTML interview questions blog. I Hope these
HTML Interview Questions will help you in your interviews. In case you have
attended any such interview in the recent past, do paste those interview questions
in the comments section and we’ll answer them. You can also comment below if
you have any questions in your mind, which you might face in your Web
Development interview.
Check out our Full Stack Web Developer Masters Program which comes with instructor-
led live training and real-life project experience. This training makes you proficient in
skills to work with back-end and front-end web technologies. It includes training on
Web Development, jQuery, Angular, NodeJS, ExpressJS, and MongoDB.
Got a question for us? Please mention it in the comments section of “HTML Interview
Questions” blog and we will get back to you.
Qusttion on DHTML
Which browsers support DHTML and how will non-supporting browsers handle DHTML?
Which browsers support DHTML? - Version of Netscape navigator and Internet Explorer higher than 4.0 or 4.0 su
way........
Working of DHTML
Working of DHTML - DHTML as it is combination of HTML as well as JavaScript and it uses the HTML to render t
What is XHTML? Why is XHTML needed? Advantages of using XHTML rather than HTML
What is XHTML? Why is XHTML needed? - XHTML stands for Extensible Hypertext Markup Language and is a c
XML. It helps us to create better formatted code for site. It makes site more accessible........