HTML Interview Questions and Answers

H

Overview:-  HTML means Hypertext Markup Language. This markup language is used for creating  web pages and also web applications.       

Hypertext:- It means a text inside a text. A text has a link inside it and that link is called hypertext. Clicking on the link will take you to a new webpage. Hypertext is a mode of linking the two or more webpages together.

Markup language:-This Markup language is used to apply the layout and the formatting conventions to a text document. With the use of Markup language, the text becomes more dynamic and interactive. It can bend the text into images, tables, links, etc.

Web Page:- It is a document which is normally written in HTML and also translated by a web browser. This web page can be determined by entering an URL. A Web page can be a static type or a dynamic type. Static webpages are created by HTML.

Do you want to get success in the HTML Interview Questions? Keep Reading the article!!!

Development History:- HTML was developed by Tim Berners-Lee and the first release of HTML was in the year 1993. Originally HTML was developed for defining the structure of documents like paragraphs, headings etc but now it is broadly used for creating the web pages

Latest Version:-The latest version of HTML is HTML5.2 which was released in the year 2017

Ques 1. Can you explain about HTML?

HTML is Hyper Text Markup Language. HTML is used for creating web applications and also web pages. HTML is regarded as the language of the internet. HTML makes the test dynamic, attractive and interactive. HTML turns the text into links, images and tables.

Ques 2. Explain the advantages of HTML.

  • The most search engine friendly programming language.
  • It is simple to create a website with HTML
  • The developer can use HTML for free
  • There is no need for extra extensions or plugins
  • HTML is supported by all the leading web browsers

Ques 3. What is the difference between HTML & XML?

S No. HTML XML
1 HTML deployed for rendering the things on the screen XML deployed for describing what the things are
2 It is human to PC interaction It is PC to PC interaction

Ques 4. Can you explain about tags in HTML?

HTML tags are a combination of three things: Opening tag, content and an ending tag. HTML being a markup language use various tags for formatting of the content. The HTML tags are boxed in the angle braces like<Tag Name>. Most of the tags have the closing tag like the closing tag of <html> is </html>, the closing tag of </body> is </body>.

Syntax-

<tag> content </tag>

This is the best HTML Interview Question particularly when you are an experienced candidate.

Ques 5. What is the role of Meta tags in HTML?

Meta tags are used by the developer to inform the browser regarding the character set, page description, keywords, author of the template and many more.

Meta tags are actually used for the SEO (search engine optimization) to inform the search engine about the contents of the page. Meta tags are written in the following way:-

<meta charset=”UTF-8″>

<meta name=”viewport” content=”width=device-width, initial-scale = 2.0″>

<meta name=”statement” content=”HTML questions and answers”>

<meta name=”writer” content=”Writer Name”>

Ques 6. Can you name the list of elements in HTML?

The list of elements are:

  • Ordered List – An Ordered List is the type of list which lists the items in a properly ordered way i.e. either arranged numbered or arranged alphabetically. The ordered list tag is written as <ol>
  • Unordered List – An Unordered List is the type of list which lists the items in an unordered way, i.e. arranged in bulleted format or arranged in any other format. The Unordered list tag is written as <ul>.
  • Definition List  – A definition List arranges the items in the way in which the items are placed in a dictionary. The definition list tag is written as <dl>

// Ordered List

01. HTML

02. Interview

03. Questions

// Unordered List

  • HTML
  • Interview
  • Questions

Ques 7. Can you explain about heading tags in HTML?

All the HTML documents start with a heading. Heading can be of different sizes. HTML has six different types of heading tag which the developer uses as per the requirement in the documents. The six HTML tags are  <h1>, <h2>, <h3>, <h4>, <h5>, <h6>. When a heading is displayed then the browser by default add one line before and after the heading.

For Example:-

<!DOCTYPE html>

<html>

<head>

<title>Example of Heading</title>

</head>

<body>

<h1>Heading 1</h1>

<h2>Heading 2</h2>

<h3>Heading 3</h3>

<h4> Heading 4</h4>

<h5>Heading 5</h5>

<h6>Heading 6</h6>

</body>

</html>

The Output of the above is:-

Heading 1

Heading 2

Heading 3

Heading 4

Heading 5
Heading 6

This is one of the most asked HTML interview questions.

Ques 8. What is a paragraph tag in HTML?

Paragraph tag structures the text into different paragraphs. The Paragraph tag is written as </p>. Each paragraph of the text should be between the opening tag <p>  and the closing tag</p>

For Example:-

<!DOCTYPE html>

<html>

<head>

<title>Paragraph Example</title>

</head>

<body>

<p>First paragraph</p>

<p>Second paragraph/p>

<p>Third paragraph.</p>

</body>

</html>

The Output of the above is:-

First paragraph

Second paragraph

Third paragraph

Ques 9. How can you create a hyperlink in HTML?

An anchor tag is written as <a>. The anchor tag in HTML is used to create hyperlinks and a path between two different HTML web pages is created. Any text which is between the opening tag <a> and the closing tag </a> becomes a link so that the user can reach to the linked document after clicking this link.

Syntax:-

<a href = “URL of the Document”… attributes-list>Link Text</a>

Hyperlinks can be displayed in three forms depending upon the developer:

  • Unvisited Link – Unvisited Links are blue in colour and they are underlined.
  • Visited Link – Visited Links are purple in colour and they are underlined.
  • Active Link – Active links are red in colour and they are underlined.

Ques 10. What is the target attribute in HTML?

The target attribute is used in HTML to indicate the location where the linked document is opened

Some of the target attributes are:-

  • _blank:-The linked document is opened in a new tab or in a new window.
  • _self:-The linked document is opened within the same frame.
  • _parent:-The linked doc is opened in the parent frame.
  • _top:- The linked document is opened in the full body of the window.
  • targetframe:-The linked document is opened in a named targetframe.

Ques 11. Write a program using an anchor tag to open youtube.

<!DOCTYPE html>
<html>

<head>
<title>Hyperlink Example</title>
</head>
            <body>
<p>Click the following link</p>
<a href = “https://www.youtube.com” target = “_self”>Youtube</a>
</body>
            </html>

The Output will be:-

Click the following link

Youtube

Ques 12. What is the structure of the HTML document?

Each page of the HTML document is different but there is a definite structure of the HTML document.

DOCTYPE tag

DOCTYPE tag is the first tag which is written in all the HTML document. DOCTYPE tag informs the browser about the type of the version the developer want to use in the particular document.

Syntax:- <!DOCTYPE html>

HTML tag

Each of the HTML document has only one <html> tag, and this HTML tag serves as a ‘container’ for the rest of the elements of the page. The rest of the html code for the page is written within the <html> tag.

Syntax:-

<html>

<!– The rest of the code –>

</html>

Body tag

Inside the  <html> tag there is a <body> tag. The body tag contains the entire content which is displayed in the browser.

Syntax:-

<body>

<h1>Welcome to this website!</h1>

<p>Content will be written here</p>

</body>

Here is the complete HTML document:-

<!DOCTYPE html>

<html>

<head>

<title>Title of the Page</title>

<meta charset=”UTF-8″>

<meta name=”statement” content=”A complete description of the page”>

</head>

<body>

<h1>Welcome to this website!</h1>

<p>Content will be written here</p>

</body>

</html>

Note: Go through this Question very thoroughly as this is one of the most important HTML interview questions.

Ques 13. What are the new features in the latest version of HTML which is HTML5?

HTML5 introduced a various semantic elements means the elements that convey meaning. Some of the semantic elements that has been added in HTML5 are <section>, <article>, <header> and  <footer>.

There are also an additional form element types such as  “number”, “calendar””date” and “range”. In the HTML5 version the video and audio elements have also been added and also new graphic elements have been added such as <svg> and <canvas>.

Ques 14. List the tags which are used while displaying the data in the form of the table?

Some of the tags which are used while displaying the data in the form of the table are:-

  • <table>-defines a table.
  • <tr>– defines a row in a table.
  • <th>-defines a header cell in a table.
  • <td>-defines a cell in a table.
  • <caption>-defines the table caption.
  • <colgroup>– For formatting, the <colgroup> specifies a group of one or more thane one columns in a table.
  • <col>-Used with the <colgroup> element to specify the column properties for each column.
  • <tbody>-Used for grouping of the body content in a table.
  • <thead>-Used for grouping of the header content in a table.
  • <tfooter>-Used for grouping of the footer content in a table.

Ques 15. Explain an image map in HTML.

Image map assists the developer to link various different web pages by using only a single image. An Image map is represented by the <map> tag. We can define the shapes in images that we want to make part of an image mapping.

Ques 16. How can you insert a copyright symbol on a browser page in HTML?

The copyright symbol can be added by using &copy; or &#169; in the HTML file.

Ques 17. Is there any tag to create a nested webpage in HTML?

The iframe tag in HTML is used to create a nested webpage. Nested webpage means webpage inside another webpage. The  <iframe> tag shows an inline frame.

For example:

<!DOCTYPE html>

<html>

<body>

<h2> Iframe example</h2>

<p>Use the height and the width attributes to define the size of the iframe:</p>

<iframe src=”Type a URL” height=”200″ width=”600″></iframe>

</body>

</html>

Ques 18. Compare between HTML and XHTML.

S No. HTML XHTML
1 HTML is a static web page XHTML is a dynamic web page
2 Hypertext Markup Language Extensible Markup Language

There are high chances of this question being asked in  HTML interview questions.

Ques 19. How can you create download links in HTML?

We can create a text link to make the DOC or PDF or ZIP  files downloadable.

For Examples:-

<!DOCTYPE html>

<html>

<head>

<title>Download Links Example</title>

</head>

<body>

<a href = “type a URL.pdf”>Download a PDF File</a>

</body>

</html>

Ques 20. Why there is a requirement of forms in HTML?

HTML Forms are used when we want to collect data from the visitor of the website. For example during a signing up on the website user fills the form to update the name, address, contact number and many more. A form takes an input from the visitor of the website and then it posts the details to a back-end application such as ASP Script, PHP script, CGI etc. The back-end application then performs the required processing on the data that has been passed based on the defined business logic within the application.

Some of the form elements are:-

  • text fields
  • textarea fields
  • drop-down menus
  • radio buttons
  • checkboxes

The <form> tag is used to create the HTML form.

Syntax:-

<form action = “URL” method = “GET|POST”>

form elements like text, textarea and many more

</form>

Ques 21. What do you mean by web-workers in HTML?

Web Workers is actually a code of JavaScript that runs in the background threads without troubling the performance of the page. Web Workers is used for computing the heavy tasks.

Ques 22. What do you mean by formatting in HTML?

Formatting is the process of formatting the text for an improved look and feel. There are many formatting tags in HTML. With the help of these formatting tags, we make bold text, italicized text, or underlined text and many more.

Ques 23. How many formatting tags are there in HTML? Explain them.

There are 12 formatting tags in HTML which are as follows:

  1. Bold Text:- If we write in between <b>…………</b> tag then the output will be a bold text
  2. Italic Text:-If we write in between <i>…………</i> tag then the output will be an italic text.
  3. HTML Marked formatting:- If we want to highlight a text on a webpage, we must write the text within <mark>….</mark> tag
  4. Underlined Text:- If we write text in between <u>………</u> tag then the output will be highlighted text.
  5. Strike Text:- If we write text in between <strike>….</strike> tag then the text is displayed with strikethrough.
  6. Monospaced Font:- If we write text in between <tt>………….</tt> tag then each letter will have a same width
  7. Superscript Text:- If we write text in between <sup>…………..</sup> tag then the font size of the content will be same as of the surrounding characters but it will be displayed half a character’s height above the other characters in the text
  8. Subscript Text:- If we write text in between <sub>…………..</sub> taghen the font size of the content will be same as of the surrounding characters but It will be displayed half a character’s height below the other characters in the text
  9. Deleted Text:- Any content which is put within the  <del>……….</del>tag is shown as the deleted text.
  10. Inserted Text:-  Any content which is put within the <ins>…..</ins>tag is displayed as an added text.
  11. Larger Text:-  Any content which is put within the <big>………</big> tag will have a font size larger than the surrounding text
  12. Smaller Text:- Any content which is put within the <small>………</small> tag will have a font size smaler than the surrounding text

LEAVE A REPLY

Please enter your comment!
Please enter your name here