10X Sale
kh logo
All Courses

Introduction

Hypertext Markup Language (HTML) is a standard markup language used to create and design web pages. HTML uses tags to mark up elements such as headings, paragraphs, images, links, and other content that appears on a web page. With HTML, web designers and developers can create web pages that are accessible, interactive, and visually appealing. Whether you are a beginner or preparing for an advanced-level developer interview, our set of HTML interview questions and the detailed answers will help you prepare for the interview more confidently.

HTML Interview Questions and Answers
Advanced

1. What Is Html5? Explain the new features

HTML5 has been developed considering current and future browser development and past, present, and future web development work. Due to this, HTML5 gained significant momentum. Driven by practicality, it has emerged as the W3C’s choice for accelerated development.

HTML5 is backward compatible and it contains all the features of the HTML4 spec, though with a few changes and improvements. It also contains additional capabilities for building dynamic web applications and creating higher quality markup.

Features of HTML5

  • New Semantic elements to allow us to define more parts of our markup unambiguously and semantically rather than using lots of classes and IDs.
  • APIs for adding video, audio, scriptable graphics, and other rich application type content to our sites.
  • HTML5 has been deliberately built to compete with proprietary plug-ins such as Flash and Silverlight.
  • New features for standardizing functionality that we already built in bespoke, hacky ways. Server-sent updates and form validation spring to mind immediately.
  • Microdata: Microdata allows machine-readable data to be embedded in HTML documents so that browsers and search engines can extract data from the page.  
  • Web Workers: Allows a JavaScript operation to work in the background without interfering with the user’s browsing.
  • Web Storage: This is a more powerful form of a cookie. It can store a large amount of data on the client side. It can store up to 5MB of data, whereas a cookie is limited to about 4KB.
  • Web Sockets: Allows pages to use the WebSocket protocol to send two-way messages between a browser and a server.
  • Cross-document and channel messaging: Cross-document messaging provides a capability to exchange documents regardless of the source domain and without enabling cross-site attacks. Channel messaging uses independent pieces of code blocks to communicate directly.
  • Server sent events: Using this feature, push notifications can be sent from a server to a client browser as DOM events.
  • New features to plug gaps in the functionality we traditionally had available in open standards, such as defining how browsers should handle markup errors, allowing web apps to work offline, allowing us to use always-open socket connections for app data transfer, and again, audio, video and scriptable images (canvas).

2. What are the new input types provided by HTML5 for forms?

Expect to come across this popular question in HTML interview questions and answers.

HTML5 introduces more than a dozen new input types for forms. The new input types provide dual benefits

  • Less development time
  • Improved user experience.   

Below are the new input types and it’s usage.

  • Search: Search is the most common action perform on the web every day. Search is not only for Google, Bing, or Yahoo, but it can be a field on e-commerce site we make a purchase from on the web, on Wikipedia, and even on a personal blog. The syntax for Search is
<input type="search" name="search">
  • Email:  Email input type is no different from a standard text input type but it allows one or more e-mail addresses to be entered with the required attribute. The browser looks for patterns to ensure a valid e-mail address has been entered. The syntax for Email is
<input type="email" name="email" required>

The URL input type is for web addresses.  The browser will carry out simple validation and present an error message on form submission. This is likely to include looking for forward slashes, periods, and spaces and possibly detecting a valid top-level domain (such as .com or .co.uk).  It also supports multiple addresses. The syntax for Url is

<input type="url" name="url" required>
  • Tel: tel does not have any particular syntax enforced. Phone numbers differ around the world, making it difficult to guarantee any type of specific notation except for allowing only numbers and perhaps a + symbol to be entered.  Validation against specific phone number format can be done using client-side validation. The syntax for tel is
<input type="tel" name="tel" id="tel" required>
  • Number: Number is used for specifying a numerical value. It, Safari, and Chrome, number input is rendered as a spinbox control whereby the user can click the arrows to move up or down or enter directly into the field. Firefox, on the other hand, renders the field like a standard text box. Support for type="number" will be in IE 10 also.  With the additional attributes min, max, and step, we can change the default step value of this spinbox control as well as set minimum, maximum, and starting values (using the standard HTML value attribute). The syntax for number is
<input type="number" min="5" max="18" step="0.5" value="9" name="shoe-size" >
  • Range: The Range input type is similar to number but more specific. It represents a numerical value within a given range. In Opera, Safari, and Chrome, type="range" renders as a slider. The syntax for range is
<input id="skill" type="range" min="1" max="100" value="0">
  • Date: HTML5 provides date control which provides a date picker functionality with is integrated with the browser without any external libraries.  Date control allows to select a single date; select a week, month, time, date and time, and even date and time with a time zone using the different input types. The markup is pretty straightforward. The syntax for Date is
<input id="dob" name="dob" type="date">

Also, using the min and max attributes to ensure the user can only choose from a specified date range.

<input id="startdate" name="startdate" min="2012-01-01" max="2013-01-01" type="date"> 
  • Month: Month is used to select a particular month on the web page. It can be used for a credit card expiry date. The syntax for month is
<input id="expiry" name="expiry" type="month" required>
  • Week: week is used to select a particular week in a month. The syntax for week is
<input id="vacation" name="vacation" type="week">
  • time : time renders a spinbox for selecting the precise time. The syntax for time is
<input id="exit-time" name="exit-time" type="time">
  • DateTime: We can combine the date and time by using type="datetime" for specifying a precise time on a given day. The syntax for datetime is
<input id="entry-day-time" name="entry-day-time" type="datetime">
  • Datetime-local: Using datetime-local, user can select a precise time on a given day with a local time zone variation. The syntax for datetime-local is
<input id="arrival-time" name="arrival-time " type="datetime-local">
  • Color: The Color input type allows the user to select a color and returns the hex value for that color. It is anticipated that users will either be able to type the value or select from a color picker,. The syntax for color is
<input id="color" name="color" type="color"> 

3. How to detect whether a browser supports a particular feature using the Modernizr library.

Modernizr is an open source, MIT-licensed JavaScript library that detects support for many HTML5 & CSS3 features. You should always use the latest version. To use it, include the following highlighted <script> element at the top of your page.

<!DOCTYPE html>
<html>
<head>
 <meta charset="utf-8">
 <title>Dive Into HTML5</title>
  <script src="modernizr.min.js"></script>
</head>
<body></body>
</html>

Following are the Apis supported by Modernizr

  • Modernizr.canvas attribute is used to detect support for the canvas API. 
  • Modernizr.canvastext attribute is used to detect support for the canvas text API.
  • Modernizr.video attribute is used to detect support for HTML5 video. 
  • Modernizr.localstorage attribute is used to detect support for HTML5 local storage. 
  • Modernizr.webworkers attribute is used to detect support for web workers.
  • Modernizr.applicationcache is used to detect support for offline web applications.
  • Modernizr.geolocation is used to detect support for the geolocation API.

4. Write code to demonstrate the scenarios Anchor Tags/ Hyperlinks

The Web is based on hyperlinks. Each Web page contains active links to other pages, which in turn link to even more pages, until presumably the entire Web (or at least a great chunk of it) is bound together. In fact, that’s where the name “web” comes from. Hyperlinks can connect to other places on a Web page, to other pages within the Web site, to pages outside the site, and to many types of Web and non-Web content.

  • Scenario 1: Hyperlinking to a Web Page.

The syntax for a hyperlink starts with <a> tag and uses an href=attribute which provides the URL or path to a destination.

E.g <a href="http://www.microsoft.com">

This is followed by the text that will appear underlined as the link text that user click, or by a reference to the image that will serve as a hyperlink

E.g Visit <a href="http://www.microsoft.com">Microsoft.com</a> for the latest information.
  • Scenario 2: Using Partial Paths and Filenames

In order to link to a specific page, the complete file name should be specified. Example, To provide a direct link to the page where users can download Windows Media Player, it should have the following tag:

<a href="http://www.microsoft.com/windows/windowsmedia/player/download/download.aspx">Download Windows Media Player</a>
  • Scenario 3: Using Relative and Absolute Paths

Paths that contain a complete address that anyone can use to get to that page are called absolute paths. Absolute paths are very reliable, but they are also long and awkward to type.

E.g <a href="http://www.microsoft.com/articles/Windows10.htm">Windows 10</a>

Instead of providing the full path only the destination file is provided, it is called a relative path. Below are the relative path examples.

<a href=" Windows10.htm">Windows 10</a>
<a href=“articles/ Windows10.htm">Windows 10</a>
  • Scenario 4: Setting a Target Window

To direct the hyperlink to open a page in a new window, add the attribute target=″_blank″ to the <a> tag. For example, to open the foliage.htm file in a new window, the tag would be structured like this:

<a href=" Windows10.htm " target="_blank">Windows10</a>
  • Scenario 5: Hyperlinking to an E-Mail Address

Hyperlinks can point not only to web pages but also to email address. Email hyperlinks are useful to send a message to a particular person directly.

<a href="mailto:support@microsoft.com">Contact Us</a>
  • Scenario 6: Creating and Hyperlinking to Anchors

An anchor is a marker within an HTML document, roughly analogous to a bookmark in a Word document. Define a specific location in the document with an anchor name, and then hyperlink directly to that anchor. Anchors are most valuable in long documents with multiple sections. They provide a means for users to jump directly to whatever section they want rather than having to read or scroll through the entire document.  

E.g

<div id="top">conclusion </div>
    <a href="#conclusion">View the Conclusion</a> # plays a critical for identifying the section

5. What is the difference between article vs section? Provide usage examples.

<section> is best used as a sub-section of an <article> and should always contain and enclose a heading, something like the following:

  • Don’t use <section> as a target for styling or scripting; use a <div> for that
  • Don’t use <section> if <article>, <aside>, or <nav> is more appropriate.
  • Don’t use <section> unless there is naturally a heading at the start of the section.
<article>
<h1>A heading, any level from h1 to h6</h1>
<section>  
<h1>A heading, any level from h1 to h6</h1>some content
</section>
<section>
<h1>A heading, any level from h1 to h6</h1>some content
</section>
 </article> 

An <article> is a stand-alone item, such as a self-contained piece of information that could be lifted from the page and published in a forum, magazine, RSS feed, or newspaper. It should contain and enclose a heading (h1 to h6) and it can contain two or more sections. The key words are STAND ALONE.

Want to Know More?
+91

By Signing up, you agree to ourTerms & Conditionsand ourPrivacy and Policy

Description

HTML is known as Hypertext Markup Language and the standard markup language used to create web pages and web applications. HTML, along with Cascading Style Sheets (CSS) and JavaScript, forms a foundation for technologies related to the World Wide Web.

HTML is free, easy to understand and use. Its syntax is quite similar to XML’s and is supported by most web development tools, not to forget that It is the most user-friendly programming language.

Moreover, it is supported by nearly all the available browsers. No other programming language is as compatible with browsers as HTML. Due to this, any web page in the HTML format can be optimized easily and will open in almost all browsers throughout the world. To learn more about HTML, you can enroll with us in our HTML course to have more knowledge and prepare better for the interview.

As a fresher in web development, one starts as an entry-level Web Developer, designing and creating websites for the client.

You may work as a Back-end Web Developer, where you will do the heavy lifting to maintain the overall technical construction of websites. You will be required to create the basic framework of the site with full expected functionality and make arrangements and changes to allow others to make changes to the website and discuss with the management about the same.

The next option is working as a Front-end Web Developer, where you will determine the looks of a website by creating the layout of the site and combining graphics, applications, and other content, not to forget writing web design programs in many computer languages like HTML or JavaScript.

Then you have the Webmasters job position, where you will ensure that the websites are properly maintained and updated, testing them for errors like broken links to ensure maximum functionality and often responding to user comments too.

According to payscale.com, the average salary for entry-level HTML Developers is $73,619, going as high as $106,468 per annum, while for experienced HTML Developers, the average salary is 96,364, going as high as $129,181 per annum. The primary companies hiring HTML developers are IBM, Microsoft Corp, HP, Google, Intel, Apple Inc, and Amazon.com Inc.

There are a host of opportunities in the world of web development for a skilled HTML Developer. All you need to crack an HTML interview is a systematic approach to prepare for the questions and answers that will help you deal with the tricky situation in the interview sessions. As we are well versed in the various difficult scenarios, our 30 HTML interview questions and answers will pack a punch to successfully crack your HTML interviews. This set of HTML questions and answers will help the freshers and prove very helpful for experienced HTML developers looking for better prospects in their line of work. Additionally, this will help you get an edge over others to get your dream HTML Developer job that you have been yearning for. To delve into more courses and upskill your career, you can join our programming training courses.

So, why wait any longer? Go at our HTML interview questions, crack any HTML job interview, and land your dream job!

Recommended Courses

Learners Enrolled For
CTA
Got more questions? We've got answers.
Book Your Free Counselling Session Today.