All HTML Interview Questions & Answers
HTML stands for HyperText Markup Language. It is used to create and format Web documents.
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>
Internal links make it easy for your users to jump to different parts of your page.
No, some tags do not come in pair.
For an example:
<img> tag and
<br> tag do not require end tags.
To insert the copyright symbol, use
© in an HTML file.
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.
HTML Tags are the labels or entity that create web pages. Each tag provides special meaning for the content.
<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>This is sample content
</p> represents HTML element.
A basic HTML page structure mainly consists of 3 HTML tags,
<!DOCTYPE html> declaration.
A standard HTML page contains
<!DOCTYPE html> in the begining. Then
<head> tag. And all main and visible page content is written inside
HTML Page Structure Example
<!DOCTYPE html> <html> <head> <title>This is a sample title</title> </head> <body> This is sample page content </body> </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
height of the image. Similarly, HTML links or anchor tag use
href attribute to provide link address.
<img src="my-picture.jpg" width="400" height="400">
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.
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.
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>
There are 3 HTML Listing tags to display a list of items.
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.
<ol> <li>Item 1</li> <li>Item 2</li> </ol>
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.
<ul> <li>Item 1</li> <li>Item 2</li> </ul>
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.