HTML
HTML
Example:
1 <!-- Text field -->
2 <input type="text" />
3 <!-- Checkbox -->
4 <input type="checkbox" />
5 <!-- Radio button -->
6 <input type="radio" value="on" />
Q4. What is the difference between a block-level element and an inline element?
Block Inline
A block-level element is drawn as a Inline elements are drawn where they
block that stretches to fill the full width are defined and only take up space that
available to it i.e, the width of its is absolutely needed. The easiest way to
container and will always start on a new understand how they work is to look at
line. how text flows on a page.
Elements that are block-level by default: Examples of elements that are inline by
<div>, <img>, <section>, <form>, default: <span>, <b>, <strong>, <a>,
<nav>. <input>.
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:
1 <!-- This is a comment! -->
2 <!-- Comments can span multiple
3 lines too -->
<!-- This part is ignored in the
browser -->
Q6. What are the HTML tags used to display the data in the tabular form?
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
It specifies a group of one or more columns in a table for
<colgroup>
formatting
This is used with <colgroup> element to specify column
<col>
properties for each column
<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:
Q8. Name some common lists that are used when designing a page.
There are many common lists used for design a page. You can choose any or a
combination of the following list types:
Syntax:
1 <a href = "..........."> Link Text
</a>
Q13. What is a Style Sheet?
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 the markup language.
• <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.
Q17. What is the difference between DIV and SPAN in HTML?
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">
2 This is <span class="Web
3 Dev">interview</span>
</div>
Syntax:
1 <iframe src="URL"></iframe>
Example:
1 <iframe src="demo_iframe.html"
width="200px"
height="200px"></iframe>
Target to a link:
1 <iframe src="<a
href="http://www.edureka.co">http://
www.edureka.co</a>"
name="iframe_a"></iframe>
Example:
1 <span style="color:#ffffff;">
2 In this page we use span.
3 </span>
Q28. Is there any way to keep list elements straight in an HTML file?
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.
Q29. Explain The Key Differences Between LocalStorage And SessionStorage Objects.
The key differences between localStorage and sessionStorage objects are as
follows:
• The localStorage object stores the data without an expiry date. However,
sessionStorage object stores the data for only one session.
• In the case of a localStorage object, data will not delete when the browser
window closes. However, the data gets deleted if the browser window closes,
in the case of sessionStorage objects.
• The data in sessionStorage is accessible only in the current window of the
browser. But, the data in the localStorage can be shared between multiple
windows of the browser.
Q30. When is it appropriate to use frames?
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.
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.
Q33. What is the hierarchy that is being followed when it comes to style sheets?
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:
1 <a
href=”mailto:youremailaddress”>text
to be clicked</a>
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
The HTML Code for the above problem is:
1 <table>
2 <tr>
3 <td>50 pcs</td>
4 <td>100</td>
5 <td>500</td>
6 </tr>
7 <tr>
8 <td>10 pcs</td>
9 <td>5</td>
10 <td>50</td>
</tr>
11
</table>
12
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.
Q42. What is the relationship between the border and rule attributes?
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.
• 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
Example:
1 <table border cellspacing=3>
2 <table border cellpadding=3>
3 <table border cellspacing=3
cellpadding=3>
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 <button onclick= "alert('Click the
Buton!');">Click me!</button>
You can define a script block anywhere on the page, which will get executed as
soon as the browser reaches that part of the document. This can be inside the
<head> or <body> section of your document.
1 <script>
2 var x = 5;
3 var y = 6;
4 var result = x + y;
5 alert(“X + Y is equal to " +
6 result);
</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.