HTML Interview Questions - Set 1

HTML Interview Questions

Next →

This page contains HTML interview questions and answers.

Q1: What is HTML?

HTML or Hypertext Markup Language as the name suggests is a markup language that is used to create web pages.

Q2: What is DOCTYPE?

DOCTYPE is the Document Type Declaration which tells the browser about the document type it receives.

In HTML5 we add the following DOCTYPE at the beginning of the file before the opening html tag.

<!DOCTYPE html>

Q3: What are HTML tags?

HTML tags are the special symbols that wraps the content and tells the browser about the content type.

Tags are in pairs and we generally have an opening tag and a closing tag.

Syntax:

<tagName> Some content... </tagName>

Where, <tagName> is the opening tag and </tagName> is the closing tag.

In the following example we are showing a paragraph tag.

<p>This content is inside the paragraph tags.</p>

Q4: Do all HTML tags comes in pair?

No. There are tags without closing pair.

Example: Input tag, Image tag, Break line tag are some without the closing pair.

In the following example we have just the opening tags.

<input type="text" name="username">
<img class="logo" src="path/to/image.png">
<br>
<hr>

Q5: Define HTML elements?

HTML element is a combination of an opening tag, the content and the closing tag.

In the following example we have a HTML element consisting of opening and closing paragraph tag and the text "Hello World".

<p>Hello World</p>

Q6: Create different types of lists in HTML

We can create the following lists in HTML

Unordered list, Ordered list and Definition list.

Example of unordered list having 3 items.

<ul>
  <li>Apple</li>
  <li>Mango</li>
  <li>Orange</li>
</ul>

Example of ordered list having 3 items.

<ol>
  <li>Apple</li>
  <li>Mango</li>
  <li>Orange</li>
</ol>

Example of definition list having 3 definitions.

<dl>
  <dt>HTML<dt>
  <dd>Hyper Text Markup Language</dd>
  <dt>CSS<dt>
  <dd>Cascading Style Sheet</dd>
  <dt>JS<dt>
  <dd>JavaScript</dd>
</dl>

Q7: What are hyperlinks in HTML?

Hyperlinks are the HTML elements that helps us to navigate from one web page to the next.

We create hyperlinks using the <a> anchor tag.

In the following example we are creating a hyperlink that will take us to the home page of dyclassroom website.

<a href="https://dyclassroom.com">Visit dyclassroom.com</a>

Q8: Create an image hyperlink

To create this we have to enclose an img tag inside the a tag.

<a href="https://dyclassroom.com">
  <img src="https://dyclassroom.com/image/dyclassroom-logo-black-311x48.png"
</a>

In the above example we have the anchor tag having href attribute set to the home page of dyclassroom website. You can use any other link. Then the src attribute of the image tag is set to the dyclassroom logo image file. You can use any other image link.

Q9: How to create comment in HTML?

Comment in HTML starts with <!-- and ends with -->.

In the following example we have commented out some HTML elements.

<p>This is the first paragraph.</p>
<!-- <p>This one is commented out.</p> -->
<p>Another para.</p>
<!--
<p>Commented out</p>
<p>Also commented out</p>
-->

Q10: Write a complete HTML file with head, title, body and a simple paragrap tags?

<!DOCTYPE HTML>
<html>
<head>
  <title>Sample HTML page</title>
</head>
<body>
  <p>Hello World</p>
</body>
</html>
Next →