HTML Interview Questions And Answers

HTML Interview Questions And Answers






1) What is HTML?

       HTML is short for HyperText Markup Language and is the language of the World Wide Web. It is the standard text formatting language used for creating and displaying pages on the Web. HTML documents are made up of two things: the content and the tags that format it for proper display on pages

2) Write the basic structure of the HTML template?

<html>
      <head>
                <title></title>
      </head>
      <body>
      </body>
</html>

3)How many types of heading does an HTML contain?

The HTML contains six types of headings which are defined with the <h1> to <h6> tags. Each type of heading tag displays different text size from another. So, <h1> is the largest heading tag and <h6> is the smallest one

4)How do you insert a comment in HTML?

Comments in HTML begins with “<!–-A SAMPLE COMMENT-–>”.

5)What is Anchor tag and how can you open an URL into a new tab when clicked?

Anchor tag in HTML is used to link between two sections or two different web pages or website templates.

To open an URL into a new tab in the browser upon a click, we need to add target attribute equal to _blank.

<a href=”#” target=”_blank”></a>

5)Does a hyperlink apply to text only?

No, hyperlinks can be used in the text as well as images. That means you can convert an image into a link that will allow users to link to another page when clicked. Surround the image within the <a href=” “>…</a> tag combinations.

6)What is a Style Sheet?

A style sheet is used to build a consistent, transportable, and well-designed style template. You can add these templates on several different web pages. It describes the look and formatting of a document written in the markup language.

7)What are the tags used to separate a section of texts?

There are three tags that can be used to separate the texts:

<br> tag – Usually <br> tag is used to separate the line of text. It breaks the current line and conveys the flow to the next line
<p> tag – This contains the text in the form of a new paragraph.
<blockquote> tag – It is used to define a large quoted section. If you have a large quotation, then put the entire text within <blockquote>……….</blockquote> tag.

8)What is the difference between DIV and SPAN in HTML?

The difference between span and div is that a span element is in-line and usually used for a small chunk of HTML inside a line,such as inside a paragraph. Whereas, a div or division element is block-line which is equivalent to having a line-break before and after it and used to group larger chunks of code.

9)The <!DOCTYPE html> tag considered as a HTML tag?

No, the <!DOCTYPE html> declaration is not an HTML tag.

There are many type of HTML, such as, HTML 4.01 Strict, HTML 4.01 Transitional, HTML 4.01 Frameset, XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1 etc. So, <!DOCTYPE html> is used to instruct the web browser about the HTML page.

10)What are inline elements and block-level elements in HTML?

 Block elements are the blocks that take the full available width and always start from a new line. It will stretch itself to the full available width of the available container width. Block-level elements are <div>, <p>, <img>, <section> and many more.
<div>Hello World</div>

Inline elements are the elements that will only take the width that is required to fit into the container.
<span>Hello World</span>