All HTML Interview Questions & Answers
The complete set of HTML Interview Questions & Answers. These FAQs focus on mostly HTML but also on CSS, JavaScript & jQuery. HTML FAQs available for freshers as well as experienced.
What is the full form of HTML?
HTML stands for HyperText Markup Language. It is used to create and format Web documents.
How to add Comments in HTML?
There are opening comment tags <!--
and closing comment tags -->
that are used to insert comments in HTML.
<!-- About Author -->
<p>This is a sample content about author. Here we can write about him in details.</p>
How do you create links to sections within the same page?
Internal links make it easy for your users to jump to different parts of your page.
Destination Anchors:
Source Anchors:
Top
Do all HTML tags require both a begin and end tag?
No, some tags do not come in pair.
For an example: <img>
tag and <br>
tag do not require end tags.
How to Add the Copyright Symbol to Web Page?
To insert the copyright symbol, use ©
or ©
in an HTML file.
What is HTML?
HTML stands for Hypertext Markup Language. It is widely used markup language to create web pages over the internet. HTML tags are used to structure & display content on websites.
What is the difference between HTML Tags & Elements?
HTML Tags are the labels or entity that create web pages. Each tag provides special meaning for the content.
For example: <p>
is paragraph tag.
HTML element is a combination of start tag, content and an end tag. Mostly, website content is written inside start tag ( <p>
) and an end tag ( </p>
).
For example: <p>
This is sample content</p>
represents HTML element.
What is the HTML page structure? Explain with example
A basic HTML page structure mainly consists of 3 HTML tags, <html>,
<head>
, <body>
and <!DOCTYPE html
> declaration.
A standard HTML page contains <!DOCTYPE html>
in the begining. Then <html>
tag starts. HTML Page title, style and javascript is included inside the <head>
tag. And all main and visible page content is written inside <body>
tag.
HTML Page Structure Example
<!DOCTYPE html>
<html>
<head>
<title>This is a sample title</title>
</head>
<body>
This is sample page content
</body>
</html>
What is attribute in HTML?
Attributes provide additional information inside HTML tags. HTML attributes are specified in the opening tag in the form of attribute name and value.
For example, HTML images can have width and height attributes to define the width
and height
of the image. Similarly, HTML links or anchor tag use href
attribute to provide link address.
Syntax: <img src="my-picture.jpg" width="400" height="400">
What is the difference between DIV, SPAN & Paragraph tag in HTML?
What is the difference between DIV, SPAN & Paragraph tag in HTML?
<div>
tag is the most common element to define a division and section. This is a block element which means it adds a line break before and after the content inside. Mostly, <div>
tag is used to create content boxes and layouts in a website.
<span>
an inline element, it only takes the required space in the same line and does not add line breaks. This is helpful for when we need to apply some styles to inline elements such as image, links or highlight piece of text.
<p>
tag is used to defines paragraphs. The content written in paragraph adds some space before and after each element just like any document paragraphs.
What do you mean by HTML Links?
Html links are used to jump on various web pages or to the same or another document. A web page contains various links in a document. The tag which is used to create a link is anchor tag i.e. <a> </a>
. The <a>
n tag defines a hyperlink, which is used to link from one page to another.
In a web browser, by default link appear like this – A visited link is underlined and purple, An unvisited link is underlined and blue, An active link is underlined and red.
How to create a link to jump to a specific part of a page in HTML?
To insert a link to a specific section of the same page, use the <a> tag with the href
attribute. In href
, you need to provide hash (#)
symbol and section id where we need to jump.
Links on the same page also known as HTML bookmarks.
Example of links to the same page
Often, we see a link on the bottom of the page which says something like “Back to Top”. When we click on it, page scrolls to the top. Here is a similar example:
<div id="header-section">This is header section content</div>
<a href="#header-section">Jump to Top Header Section</a>
What are different tags to list items in HTML?
There are 3 HTML Listing tags to display a list of items.
Ordered List:
HTML ordered list starts with the <ol>
tag and items are listed in <li>
tag. This is used when we need to provide list of items marked with numbers or similar format.
Example
<ol>
<li>Item 1</li>
<li>Item 2</li>
</ol>
Unordered List:
HTML unordered list starts with the <ul>
tag and items are listed in the same <li>
tag. This is used when we need to provide list of items marked with bullets or similar symbols.
Example
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
Description List:
An HTML description list provides a list of terms, with a description of each term.
<dl>
<dt>HTML</dt>
<dd>HTML stands for Hypertext Markup Language</dd>
<dt>Computer</dt>
<dd>Computer is a machine or device for storing and processing data</dd>
</dl>
Most of the time, we only use Ordered and Unordered lists in HTML. Sometimes, we refer to another <datalist>
tag but it has different use to list of pre-defined options for an <input>
element. This is introduced in HTML5.