HTML Interview Questions and Answers - HTML Interview

HTML Interview Questions and Answers - HTML Interview

We always provide mostly asked questions during the interview. If you prepare these questions properly, i assure you that you will crack your interview.

HyperText Markup Language (HTML) is a markup language for creating a webpage. Webpages are usually viewed in a web browser. They can include writing, links, pictures, and even sound and video. HTML is used to mark and describe each of these kinds of content so the web browser can display them correctly.

Que 1:- What is HTML and why we use it?

Ans:-  HTML is the standard markup language for creating Web pages.

  • HTML stands for Hyper Text Markup Language
  • HTML describes the structure of Web pages using markup
  • HTML elements are the building blocks of HTML pages
  • HTML elements are represented by tags
  • HTML tags label pieces of content such as "heading", "paragraph", "table", and so on
  • Browsers do not display the HTML tags, but use them to render the content of the page

Que 2:- What is current version of HTML?

Ans:- Current version of HTML is HTML5.2.

Que 3:- What are Tags?

Ans:- HTML tags are element names surrounded by angle brackets:

  • HTML tags normally come in pairs like <p> and </p>
  • The first tag in a pair is the start tag, the second tag is the end tag
  • The end tag is written like the start tag, but with a forward slash inserted before the tag name

Que 4:- What is full form of HTML?

Ans:-  HTML stands for Hyper Text Markup Language.

Que 5:- Can you write the basic structure of the HTML template?

Ans:-  All HTML documents must start with a document type declaration: <!DOCTYPE html>.

The HTML document itself begins with <html> and ends with </html>.

The visible part of the HTML document is between <body> and </body>.

For Example.

<!DOCTYPE html>
<html>
<body>

<h1>My First Heading</h1>
<p>My first paragraph.</p>

</body>
</html>

Que 6:- Do all HTML tags come in a pair?

Ans:-  HTML is a markup language, wherein the browser needs to know which content should be interpreted in which manner. For that reason, all related content need to be enclosed within a pair of HTML tags i.e. one opening and the other closing tag. e.g. A pair of section tags would be

Opening tag

<section>

Closing tag

</section>

However, there are some tags which don’t have any content in them and so they are called self closing tags. e.g. <br /> <hr /> <img /> <area /> , etc.

Que 7:- What are some of the common lists used in a web-page?

Ans:-  HTML offers web authors three ways for specifying lists of information. All lists must contain one or more list elements. Lists may contain −

  • <ul> − An unordered list. This will list items using plain bullets.

  • <ol> − An ordered list. This will use different schemes of numbers to list your items.

  • <dl> − A definition list. This arranges your items in the same way as they are arranged in a dictionary.

Que 8:- In which year HTML was first time proposed?

Ans:- In 1980, physicist Tim Berners-Lee has been proposed.

Que 9:- Can you explain the formatting in HTML?

Ans:-  HTML has special elements for defining text with a special meaning.

HTML uses elements like <b> and <i> for formatting output, like bold or italic text.

Formatting elements were designed to display special types of text:

  • <b> - Bold text
  • <strong> - Important text
  • <i> - Italic text
  • <em> - Emphasized text
  • <mark> - Marked text
  • <small> - Small text
  • <del> - Deleted text
  • <ins> - Inserted text
  • <sub> - Subscript text
  • <sup> - Superscript text

Que 10:- What is HTML5 ?

Ans:- HTML5 is the latest and most enhanced version of HTML. Technically, HTML is not a programming language, but rather a markup language. In this tutorial, we will discuss the features of HTML5 and how to use it in practice.

Que 11:- How we can insert a comment in HTML?

Ans:- The comment tag is used to insert comments in the source code. Comments are not displayed in the browsers.

<!-- Hi i am comment. Comments are not displayed in the browser -->

<p>This is a paragraph.</p>

Que 12:- Difference between HTML and XML?

Ans:- XML and HTML are the markup languages defined for the distinct purposes and have several differences. The prior difference is that in XML there are provisions for defining new elements while HTML doesn’t provide a specification to define new element and it uses predefined tags. XML can be used to build markup languages while HTML itself is a markup language.

XML:- XML (Extensible Markup Language) is a language that enables a user to define a representation of data or data structure where values are assigned in each field in the structure. IBM devised it as a GML (Generalized Markup Language) in 1960’s. When the IBM’s GML is adopted by ISO, it named as SGML (Standard Generalized Markup Language) and it was the foundation for the complex documentation system. XML language provides a platform to define markup elements and generate customized markup language. In XML to create a language or elements, one must follow some set of rules defined in the XML. The XML document includes data as strings and text which is surrounded by text markup. The fundamental unit in the XML is known as an element.

HTML:- HTML (Hypertext Markup Language) is the markup language for constructing web pages. The markup commands employed in the web-based content signifies structure of the document and its layout to the browser. Browsers simply read the document with the HTML markup in it and render it on the screen through examining the placed HTML elements in the document. An HTML document is considered as a text file that holds the information need to be published.

Que 13:- What is the advantage of collapsing white space?

Ans:- The advantage of collapsing whitespace is that the HTML code becomes neat and is in a much more readable form. Blank spaces in HTML are treated as a single space character. So, the browser makes multiple spaces into a single space, codes can be written without worrying about the multiple spaces.

Que 14:- Who is the author of HTML?

Ans:- Tim Berners-Lee is the author of HTML.

Que 15:- How many types of heading does an HTML contain?

Ans:-  Headings are defined with the <h1> to <h6> tags.

<h1> defines the most important heading. <h6> defines the least important heading.

<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>

Que 16:- What are new features in HTML 5?

Ans:- 

  1. The video element allows you to easily stream video from a website.
  2. Figure elements can be used to display visual content, such as photos, illustrations, diagrams or code snippets.
  3. Section elements, like divs, can be used to organize webpage content into thematic groups.
  4. The nav element is used for the part of a website that links to other pages on the site. The links can be organized a number of ways. Below, the links are displayed within paragraph elements. An unordered list could also be used.
  5. The header element can be used to group together introductory elements on a website, such as a company logo, navigation items, and sometimes, a search form.
  6. The footer element is typically found at the bottom or foot of a webpage. It can contain copyright information, links to social media and additional site navigation items.

 

Que 17:- Do all character entities display properly on all systems?

Ans:- No, there are some character entities that cannot be displayed when the operating system that the browser is running on does not support the characters. When that happens, these characters are displayed as boxes.

Que 18:- Can we keep list elements straight in an HTML file?

Ans:- Yes, it is possible to list the elements in straight line in html. This can be done by using indents for it. Indents specify the amount of white space that is put before texts.

Que 19:- What is the meaning of markup in HTML?

Ans:- Markup is a symbol or character that you insert at certain place in a text file. This represents how the file should look (bold, italic, link, etc) when it is printed in your browser.
Also the markup indicators are often called "tags."

Que 20:- What is a physical tag and logical tag in HTML?

Ans:- Physical tags are used to indicate exactly how specific characters are to be formatted.

<b>Displays the bold text on the Web page</b>

The logical tags specify that the enclosed text has a specific meaning, context, or usage. For example, the ABBR tag conveys to the Web browser that the text enclosed inside this tag is an abbreviation. 

<ABBR>Displays the abbreviation on the Web page</ABBR>

Que 21:- How to create a hyperlink in HTML?

Ans:- In HTML, links are defined with the <a> tag. You can click on a link and jump to another document.

Example:- 

<a href="https://www.phpinterview.in">HTML Interview Questions</a>

Que 22:- Does a hyperlink apply only to text?

Ans:- 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.

Example:- 

<a href="http://phpinterview.in"><img src="path_to_your_image" /></a>

Que 23:- Which HTML tag is used to display the data in the tabular form?

Ans:- <table> tag is used to display the data in the tabular form.

Example:-

<table style="width:100%">
  <tr>
    <th>Firstname</th>
    <th>Lastname</th> 
    <th>Age</th>
  </tr>
  <tr>
    <td>Jill</td>
    <td>Smith</td> 
    <td>50</td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td> 
    <td>94</td>
  </tr>
</table>

Que 24:- Define Semantic elements in HTML ?

Ans:- A semantic element is an element of code that uses words to clearly represent what that element contains, in human language. For practical purposes, many of those researching semantic elements are looking at English language words used for the purposes of semantic labeling.

some semantic elements are

<form><table>, and <article> - Clearly defines its content.

Que 25:- Define attributes in HTML tag ?

Ans:- 

  1. All HTML elements can have attributes
  2. Attributes provide additional information about an element
  3. Attributes are always specified in the start tag
  4. Attributes usually come in name/value pairs like: name="value"

HTML links are defined with the <a> tag. The link address is specified in the href attribute.

Que 26:- Can attribute values be set to anything or are there specific values that they accept?

Ans:- Some attribute values can be set to only predefined values. Other attributes can accept any numerical value that represents the number of pixels for a size.

Que 27:- Can we modify the attribute’s value of the HTML tag dynamically ?

Ans:-  Yes, we can modify the value of the attributes by using JavaScript.

Below is the input element whose attribute will be modified from text to password, JS code to modify the attribute value:

<input type=“text” id=“inputField”>
document.getElementById(“inputField”).attr(“type”, “password”);

Que 28:- What is an image map?

Ans:-  The <map> tag is used to define a client-side image-map. An image-map is an image with clickable areas.

The required name attribute of the <map> element is associated with the <img>'s usemap attribute and creates a relationship between the image and the map.

<img src="planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" href="sun.htm" alt="Sun">
  <area shape="circle" coords="90,58,3" href="mercur.htm" alt="Mercury">
  <area shape="circle" coords="124,58,8" href="venus.htm" alt="Venus">
</map>

Que 29:- What is the use of alternative text in image ?

Ans:- The alt attribute specifies an alternate text for an area, if the image cannot be displayed. The alt attribute provides alternative information for an image if a user for some reason cannot view it (because of slow connection, an error in the src attribute, or if the user uses a screen reader).

Que 30:- What is the hierarchy that is being followed when it comes to style sheets?

Ans:- They are generally three types of style sheets when CSS is getting added to HTML page.

  1. Inline styling
  2. Internal styling
  3. External styling

Cascading is one on top of the other and precedence of these sheets are inline, internal and external under normal conditions. Which means external styling is override by internal and internal styling is override by inline. Inline styling takes first precedence followed by internal and external.

But it's best practice to add all your styles in external style sheet as it's easy to add and edit contents when file grows big and for bigger applications.

Your Rating: