HTML Interview Questions

What is the difference between xhtml, html 4 and html 5? Which one do you use typically?

XHTML was the cleaner and stricter version of HTML-4. Whereas HTML5 is the latest, smartest, and fastest version of HTML.

Does HTML needs complier?

HTML, CSS and JS are browser interpreted technologies. Whereas asp.net, java and php are not interpreted. They need a compiler which can convert their code in machine language. That's why HTML, CSS and Javascript are also called front-end technologies.

What is Semantic HTML?

HTML5 introduced semantic tags like header, nav,article,section, aside, footer and figcaption. These tags convey the containing content. Whereas in html4, div tag was used to create partitions using descriptive classes.

Which is best HTML debugging tool.

We use chrome, firefox and firebug Dev tools as they are browser inbuilt. But W3C Validation is best HTML Debugging tools.

How to use HTML5 New tags in IE8 and lesser.

HTML5 semantic tags like, header, nav,article,section, aside, footer and figcaption are not supported in HTML4based browsers like IE8 and lesser. We can use html5shiv.js to run these elements in older browsers.
→ See More html5 tags in IE8

What is web accessibility?

Web accessibility means a web for differently abled or disabled people. HTML5 introduced WAI ARIA so that even disable people can interact, understand and navigate a website.

Difference between <b> and <strong> tag?

<b> is a presentational element used to give bolder look to text. Whereas <strong> gives bolder look and strong importance in search results.

Difference between <i> and <em> tag?

<i> is a presentational element used to give italic look to text. Whereas <em> gives italic look and emphasise in search results.

CSS Interview Questions

Difference between reset.css and normalize css?

reset.css removes all build-in browsers styling like, margin, padding and border. But normalize.css gives a common book like appearance, like bold heading, margin between two paragraphs, common font-family, etc.

What is CSS Box Model?

CSS Box Model includes content, margin, padding, and border. Total width is equal to width + padding + margin + border. These properties occupies space on box model.
→ See More CSS Box Model

How to check coding errors in css?

Open your webpage in firefox. Press Ctrl + shift + j. You will see all security, javascript and css related issues.

Difference between display none and visibility hidden ?

Visibility:hidden hide the content from user but retain space. Whereas Display:none hide the content and remove space.

How to center align a div tag in css?

Div is block level element. By default, div occupy 100% width of parent element. To center align a div in css, use

<style>
 .wrap{ 
     width:960px;
     margin:auto;
 }
 </style>
 <div class="wrap"<
     // content for wrap div
 </div>

Difference between Position Relative, Absolute and Fixed

Position relative can move a element with respect to its current position. Position absolute can move a element with respect to its current position or parent elements position. Absolute Elements doesn't occupy space in DOM Flow. Position fixed gives fixed position to an element with respect to device screen. These elements doesn't move on scrolling. Fixed Elements also doesn't occupy space in DOM Flow.
See More CSS Positions


Javascript Interview Questions

Is javascript case sensitive?

Yes, Javascript is case sensitive.

What is difference between == and === operator?

== is comparison operator, whereas === is hard equality. == checks value only, === check value and datatype. 5=="5" id true, but 5==="5" is false.

What is output of "20" + 20?

"2020". First 20 is string type, second is numeric, for addition, both should be numeric.

What is output of "20" + 20 + 20 and "20" + ( 20 + 20)?

"20" + 20 + 20 = "202020". "20" + ( 20 + 20) is "2040".

How to convert "20" to number?

Three ways to convert string into number


           var x="20";
            Number(x)       //  20 
            parseInt(x)     //  20
            parseFloat(x)   //  20
        

What is an AJAX request and what is a simple example of where a AJAX request would be used.

AJAX is Asynchronous JavaScript and XML. It is client side process to get or post data from remote server without reloading page.

What is Javascript Hoisting?

A variable is declared first and then call. If variable is declared on bottom and called earlier, value will be undefined. Only assigned values are hoisted in javascript, like string, numbers etc. Undefined and function declaration can be called before declaration as there is no assignment operator (=) in both

What is an AJAX request and what is a simple example of where a AJAX request would be used.

AJAX is Asynchronous JavaScript and XML. It is client side process to get or post data from remote server without reloading page.

Event bubbling and Event Capturing.

Event Propagation are the order that event fire on element. Bubbling is when a event fire on the element and then bubble up DOM Tree. Means First child and then parent will call. Capturing is exactly opposite. First parent node is called and then propagates down towards target element. Event Bubbling and capturing