HTML Interview Questions

HTML is not a programming language - it is a markup language that defines the structure of your content.

H- Hyper, T-Text, M-Markup, L-Language (HTML), means it is a language which contais text, symbols, graphics, and links is called HTML. It is the standard markup language for creating web pages and web applications. With the help of Cascading Style Sheets (CSS) and JavaScript (JS).

html interview question

History of the Web- The internet is a worldwide system of computer networks - a network of networks in which users at any one computer can, if they have permission, get information from any other computer menas that sometimes talk directly to users at other computers.

Q1- Explain the hierarchy of HTML document.

HTML is a Hypertext Markup Language; HTML is a computer language used to create Web pages. Each page created in HTML contains the data to be included in the Web page and the HTML tags. The Web Browser understands these tags and display the corresponding Web page. We browser the World Wide Web (www) using a Web Browser. All text, graphics and design elements of a Web page are "tagged" with codes that instruct the Web browser how to display the files.

The hypertext called hyper because the navigation through th pages using the hypertext is not lineat. It means that if you click the hypertext present on a Web page, you are directed to the relevant page on the website or Internet, which is not necessarily the next page on the website. More Details →

Q2- Why to use doctype in HTML?

The <!DOCTYPE> declaration should be the very first thing in an HTML document, before the tag. The doctype declaration is not an HTML tag; it is an instruction to the web browser about what version of the markup language the page is written in. Which specifies the Document Type Definition (DTD) used by the document. The browser checks the code of the document against the rules in <!DOCTYPE> declaration. The <!DOCTYPE> element does not have a closing tag. More Details →

HTML 4.01, HTML5 spacifies three types of DTD's:

  • HTML5 → <!DOCTYPE html>
  • HTML 4.01 Strict DTD → <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  • HTML 4.01 Transitinal DTD → <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  • HTML 4.01 Frameset DTD → <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">

Q3- What is the HTML Editors?

The web pages can be created and modified by using professional HTML editors. For the learning HTML we can use a simple text editor like Notepad (For Windows PC) or TextEdit (Mac). More Details →

Q4- How to use HTML Editors?

Write HTML code Using Notepad/TextEdit

For Notepad (PC)
  • Windows 8 or later : Open the Start Screen (the window symbol at the bottom left on your screen). Just type notepad and open it.
  • Windows 7 or earlier : Open Start > Programs > Accessories > Notepad
For TextEdit (Mac)
  • Open Finder > Applications > TextEdit - Also change some preferences to get the application to save files correctly. In Preferences > Format > choose "Plain Text"

Q5- What is the difference between HTML elements and tags?

HTML Elements - An HTML element is an individual component of an HTML document. HTML is composed of a tree of HTML nodes, such as text nodes. More Details →

  • Each part of a web page, such as a paragraph, an image, a link or anything else you can interact with, is an element.
  • Each type of element has its own behavior - for example you can click on links, or type in text boxes.
  • Each node can have HTML attributes specified.
  • Nodes can also have content, including other nodes and text.
  • Many HTML nodes represent semantics, or meaning.
  • An HTML element usually consists of a start tag and end tag, with the content inserted in between

HTML Tags - Most tags have opening and closing tags; the opening tag is written with the tag name in angled brackets, like </open_tag> whereas the closing tag adds a forward slash: </close_tag>. Anything between these opening and closing tags is considered to be contents of that tag.

  • An HTML document is a simple, plain text document, which you are able to open with any text editor on your computer. When you open one, you’ll see the document is made up of tags, which are keywords surrounded by angled brackets, each of which describes an HTML element.
  • Some tags, like the <img> tag are self-closing. This means that they cannot have any content. It is also called Empty Tag like- br, hr, img etc.

Q6- What are some of the common lists that can be used when designing a page?

Lists are used to group together related pieces of information so they are clearly associated with each other and easy to read. In modern web development, lists are workhorse elements, frequently used for navigation as well as general content. HTML Lists are used to specify lists of information. All lists may contain one or more list elements. More Details →

  • Ordered list - The ordered list displays elements in numbered format. It is represented by <ol> tag.
  • Unordered list - The unordered list displays elements in bulleted format. It is represented by <ul> tag.
  • Definition list - The definition list displays elements in definition form like in dictionary. The <dl>, <dt> and <dd> tags are used to define description list.
  • Menu list & Directory list

Q7- What is semantic HTML?

Semantic HTML is a coding style. It is the use of HTML markup to reinforce the semantics or meaning of the content. For example - In semantic HTML <b> </b> tag is used for bold statement as well as <i> </i> tag is used for italic. Instead of these we use <strong> </strong> it is almost similar like b tag and <em> </em> tags.

Q8- What are attributes and how do you use them?

HTML attribute is a modifier of an HTML element type. An attribute either modifies the default functionality of an element type or provides functionality to certain element types unable to function correctly without them.

  • In HTML syntax, an attribute is added to an HTML start tag.
  • All HTML elements can have attributes.
  • HTML Attributes provide additional information about an element.
  • Attributes are always specified in the start tag.
  • The HTML Attributes usually come in name/value pairs for Example : attribute="value"

Q9- Do older HTML files work on newer browsers?

Yes, older HTML files are compliant to the HTML standard. Most older files work on the newer browsers, though some features may not work.

Q10- What is an image map?

It is very useful to link HTML web page OR Image map facilitates use to link many different web pages using a single image. It is represented by <map> tag. You can define shapes in images that you want to make part of an image mapping.

Q11- What’s the difference between a block-level element and an inline element?

Each element in HTML is displayed in one of a few ways. By default, most tags are either displayed as block-level or inline. This value can be overridden using CSS.

Block Level Element - A block-level element is drawn as a block that stretches to fill the full width available to it the width of its container and will always start on a new line.

Examples of Elements - That are block-level by default: <div>, <img>, <section>, <form>, <nav>.

Inline Element - Inline elements are drawn where they are defined and only take up space that is absolutely needed. The easiest way to understand how they work is to look at how text flows on a page. When a line of text gets to the end of the space available, it wraps onto the next line and happily keeps going.

Examples of Elements - That are inline by default: <span>, <b>, <strong>, <a>, <input>.

Q12- 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> opening and close tag and href attribute combinations.

Q13- What is the advantage of grouping several checkboxes together?

  • Although checkboxes don’t affect one another, grouping checkboxes together help to organize them.
  • Checkbox buttons can have their name and do not need to belong to a group.
  • A single web page can have many different groups of checkboxes.

Q14- How to create a nested webpage in HTML?

The HTML iframe tag is used to display a nested webpage. In other words, it represents a webpage within a webpage. The HTML <iframe> tag defines an inline frame.

Example Explained -

<!DOCTYPE html>
 <html>
   <body>
     <h2>This is nested web page using iframe.</h2>
     <iframe src="http://wwww.gdatamart.com" height="300" width="400"></iframe> 
   </body>
 </html>

Q15- What are the limits of the text field size?

The default size for a text field is around 13 characters. However, if you include the size attribute, you can set the size value to be as low as 1. The maximum size value will be determined by the browser width. If the size attribute is set to 0, the size will be set to the default size of 13 characters.

Q16- What is the HTML5?

The history of internet, there have been many versions of the HTML standard. The versions varied in features and how strict they were. In 2014, the official recommendation for HTML5 by the World Wide Web Consortium was released. It is a living standard, meaning new features can be added over time. It is the version HTML5.

Q17- What new features were added to HTML5?

In HTML5 some of the new semantic elements are added like - <header>, <footer>, <section>, and <article>. They are semantic in that they are not just simple containers, but they tell the browser more about their contents.

There are additional form element types, like 'number', 'date', 'calendar' and 'range'. Video and audio elements have also been added, as well as new graphic elements, such as <svg> and <canvas>.

Q18- What is a marquee?

A marquee allows you to put a scrolling text in a web page. To do this, place whatever text you want to appear scrolling within the using <marquee> and </marquee> tags.

Q19- Explain the layout of HTML5?

Following are different HTML5 elements which are used to define the different parts of a webpage.

  • Header - Used to define a header for a document or a section.
  • Nav - It is used to define a container for navigation links
  • Section - It is used to define a section in a document
  • Article - It is used to define an independent, self-contained article
  • Aside - aside used to define content aside from the content like sidebar.
  • Footer - It is define a footer for a document or a section

Q20- What is a class? What is an ID?

Class - A class is a style that can be applied to one or more HTML elements. This means it can apply to instances of the same element or instances of different elements to which the same style can be attached. Classes are defined in CSS using a period followed by the class name. It is applied to an HTML element via the class attribute and the class name.

ID Selector - An ID selector is a name assigned to a specific style. In turn, it can be associated with one HTML element with the assigned ID. Within CSS, ID selectors are defined with the # character followed by the selector name. One most think, One ID selector with uniqe name can call only one time in a HTML webpage

Q21- How to create comment in HTML?

In HTML Comment starts with <!-- and ends with -->. For more understanding follow example we have commented out some HTML elements.

Example Explained -

<!DOCTYPE html>
 <html>
    <body>
      <h2>This is a heading in web page</h2>
      <!-- <h2> one is comment out.</h2> --> 
    </body>
 </html>

Q22- How are tags migrated from HTML4 to HTML5?

Typical_HTML5 Typical_HTML4
<header> <div id="header">
<menu> <div id="menu">
<content> <div id="content">
<post> <div id="post">
<footer> <div id="footer">

Example HTML4 -

<div id="header">
  <h2>This is a heading in web page</h2>
</div>

Example HTML5 -

<header>
  <h2>This is a heading in web page</h2>
</header>

Q23- What are two types of Web Storage in HTML5?

There are two types of Web Storage in HTML5

Session Storage - Session stores data of current session only. It means that the data stored in session storage clear automatically when the browser is closed.

Local Storage - Local storage is another type of HTML5 Web Storage. In local storage, data is not deleted automatically when the current browser window is closed.

GDATAMART

We are optimized for learning and job information. We try to improve your knowledge and practical experience through this site but we cannot warrant full correctness of all content. Our Privacy & Policy →

© 2019 gdatamart.com | All Rights Reserved