HTML Interview Questions
This page contains HTML interview questions and answers.
HTML
?HTML or Hypertext Markup Language as the name suggests is a markup language that is used to create web pages.
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>
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>
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>
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>
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>
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>
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.
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>
-->
<!DOCTYPE HTML>
<html>
<head>
<title>Sample HTML page</title>
</head>
<body>
<p>Hello World</p>
</body>
</html>
ADVERTISEMENT