HTML Interview Questions - Set 3

HTML Interview Questions

Share

This page contains HTML interview questions and answers.

Q1: How to use JavaScript in HTML page?

We can create script tags and write JavaScript code like the following.

<script>
document.write("Hello World");
</script>

Or we can include an external JavaScript file in the HTML page using the script tags.

<script src="path/to/script.js"></script>

Q2: Create an email link to contactus@example.com?

To create an email link we have to set the href attribute of an anchor tag to the desired email address as shown below.

<a href="mailto:contactus@example.com">Contact us</a>

Q3: What are the heading types supported by HTML?

HTML supports 6 types of heading from h1 to h6.

<h1>Hello World</h1>
<h2>Hello World</h2>
<h3>Hello World</h3>
<h4>Hello World</h4>
<h5>Hello World</h5>
<h6>Hello World</h6>

Q4: How to create telephone link in HTML?

We create telephone links in HTML as follows.

<a href="tel:+910000000000">Contact Us: +91 00 000 00000</a>

Q5: How to redirect user to a page in HTML?

For that we have to create a meta tag in the head of the page and set the following attributes.

<meta http-equiv="refresh" content="0; url=https://www.dyclassroom.com" />

Q6: What are iframes?

iframes are the HTML elements that allows us to embed document within the current HTML page.

Q7: Write the difference between GET and POST method in HTML?

Both the GET and POST methods are used to send request to the server.

The GET method is mostly used to fetch data from the server.

The POST method is mostly used to send data to the server.

Q8: Write the difference between form submission using GET method and POST method?

Following are the differences between GET and POST method form submission.

GET POST
The form data is appended in the URL and set as name/value pair. The form data is appended inside the body of the HTML request.
There is a character limit for GET request (like 2048 characters) There is no limit for the POST request.
Form-data via GET can be easily bookmarked. Form-data via POST can't be bookmarked.
This is not recommended when submitting sensitive data like user login email and password as it can be bookmarked and misused later. This is preferred when submitting sensitive data as it can't be bookmarked.

Q9: How to change font size of a paragraph just using HTML tags?

For this we can use the font tags.

In the following example we are changing the font size of a piece of text to 20 pixels using font element.

<p>The quick <font size="20">brown fox</font> jumps over the lazy dog.</p>

Q10: What is the difference between Block and Inline elements?

Block element always starts from a new line and takes up the entire width available.

Inline elements don't starts from a new line and takes up only necessary width.

Some of the block elements are listed below:

div
form
p
table

Some of the inline elements are listed below:

span
a
sup
sub
Share