The aim of this article is to provide a wide range of questions that a web developer can be asked during a job interview. Preparing for a job interview can be a daunting process if the scope of what is to be asked is so large. Web development includes a considerable set of skills and langauges, and an interview of this scale is sure to be all inclusive regarding the various web technologies.
However, as long as the focus is not on any specific langauges (which is not common for today’s programmer hiring), questions are expected to be general and explore the most important concepts of the main languages/technologies used in the web as well as personal best practices of the candidate.
Web developers are responsible for managing the way content appears to the users on a particular website. The field includes working with programming languages to create web applications that combine databases and other tools to create company’s web managment systems. However, apart from the complex part, it can also be about creating static pages and designing stuff.
As big data is more and more part of systems, its manipulation and maintenance may as well come with errors, which then will have to be debugged by members of the web development team in companies. In a general viewpoint, web developers are the ones who work behind the scenes to provide not just sites, but services people use everyday. While there are a lot to be asked in such interviews, let us have a look at what most of these questions might be.
2. General Questions
1. How would you use persistent storage on browsers? What options would you use?
For HTML browsers, a good choice would be local storage and persistent storage. For non-HTML ones, cookies are the best bet.
2. What is W3C?
W3C stands for World Wide Web Consortium which is the international standard for World Wide Web. W3C is constantly busy trying to standardize the web and to make it accessible to all users. The company was created in 1994.
3. What are two common ways in which you can reduce the load time of a web application?
There are quite a lot of ways you can reduce load time:
4. What is graceful degradation?
Graceful degradation refers to the property that enables a system to function properly even in the event of failure of either the system or a component of it.
5. What is DTD?
DTD stands for Document Type Declaration and it tells the browser which version of either HTML or XHTML is being used.
6. What is the difference between “Web development” and “Web design”.
Web development includes a lot of processes, and Web Design is part of it. Web design is used to represent page layouts and graphical user interface. Web development is a wider term to mean planning, coding, testing, debugging etc.
7. What is CORS? How does it work?
Cross-origin resource sharing (CORS) is a mechanism that allows many restricted resources (e.g. fonts, js etc.) on a web page to be requested from another domain outside the domain from which the resource originated. It’s a mechanism supported in HTML5 that manages XMLHttpRequest access to a domain different.
8. Describe the key advantages of HTTP/2 as compared with HTTP 1.1.
HTTP/2 among other improvements, provides decreased latency to improve page load speed by supporting:
9. How do you optimize a website’s assets?
There are several ways to do this, for example: file concatenation, file compression, CDN Hosting, offloading assets, refining code etc.
10. What web browser do you use?
Because web developers should be familiar with all browsers in terms of testing their web projects the best answer here is: All of them.
11. What’s the difference between standards mode and quirks mode?
Quirks mode is a default compatibility mode and may be different from browser to browser, which may result to a lack of consistency in appearance from browser to browser.
12. Explain what is long polling?
Long polling is a web application development pattern used to emulate pushing data from the server to the client. With long polling, the client requests information from the server in a similar way to a normal poll. However, if the server does not have any information available for the client, instead of sending an empty response, the server holds the request and waits for some information to be available.
3. HTML & HTML5 Questions
13. What is HTML?
HTML stands for HyperText Markup Language. It is the most popular markup language for creating websites that can be viewed in a web browser.
14. What is the difference between HTML elements and tags?
HTML elements communicate to the browser how to render text. When surrounded by angular brackets <> they form HTML tags, which come in pairs and surround text.
15. What does
DOCTYPE means Document Type Definition and tells the browser which type of HTML is used on a webpage. Browsers use
DOCTYPE to determine how to render a page. Failing to use
DOCTYPE will load your page in Quirks Mode.
16. What are the limitations when serving XHTML pages?
The main limitation is the poor browser support of XHTML. Internet Explorer and other user agents cannot parse XHTML as XML. Thus, it is not that extensible language as one might think.
17. What is the syntax difference between a bulleted list and numbered list?
Bulleted lists use the
<ul> tag, which stands for “unordered,” whereas
<ol> is used to create an ordered list.
18. What is the difference between a
<div> and a
<div> is a container element for grouping and styling, whereas a
<frame> creates divisions within a web page and should be used within the
<frameset> tag. The use of
<frameset> are no longer popular and are now being replaced with the more flexible
<iframe>, which has become popular for embedding elements from other websites (ie. Youtube videos) into a page.
19. What is the difference between the application model of HTML and HTML5?
There is not a big difference between the two. HTML5 is a continuum of HTML. There has been no major paradigm shift.
From a broader viewpoint, HTML was a simple language for laying out text and images on a webpage, whereas HTML5 can be viewed as a development platform that does what HTML does that and more, including better support for audio, video, and interactive graphics. It has a number of new elements, supports offline data storage for applications, and has more robust exchange protocols.
20. What are some new HTML5 markup elements?
Among several: <article>, <aside>, <bdi>, <command>, <details>, <figure>, <figcaption>, <summary>, <header>, <footer>, <hgroup>, <mark>, <meter>, <nav>, <progress>, <ruby>, <rt>, <section> and <time>.
21. What are the new image elements in HTML5?
The new image elements in HTML5 are Canvas and WebGL.
<canvas> is a new element that acts as a container for graphical elements like images and graphics. WebGL stands for Web Graphics Language, a free cross-platform API that is used for creating 3D graphics in web browsers.
22. What are data- attributes good for?
23. Describe the difference between cookies, sessionStorage, and localStorage.
Cookies are small text files that websites place in a browser for tracking or login purposes, and hold a modest amount of data. Meanwhile, localStorage and sessionStorage are new objects, both of which are storage specifications but vary in scope and duration. Local storage is more secure, and large amounts of data can be stored locally, without affecting website performance. Futhermore, is it permanent. sessionStorage only lasts as long as the duration of the longest open tab.
24. What are some of the major new API’s that come standard with HTML5?
Among others: Media API, Text Track API, Application Cache API, User Interaction, Data Transfer API, Command API, and the History API.
25. What is the difference in caching between HTML5 and the old version of HTML?
26. What is image map?
An image map is a list of coordinates relating to a specific image, created in order to hyperlink areas of the image to different destinations (as opposed to a normal image link, in which the entire area of the image links to a single destination).
27. What is the advantage of collapsing white space?
White spaces are blank sequences of space characters, which is actually treated as a single space character in HTML. The browser collapses multiple space into a single space, so we can indent lines of text without worrying about multiple spaces. This enables us to organize the code into a much more readable format.
28. Do all HTML elements need both opening and closing tags?
Not really, elements like
<img src=""/> or
<input type=""/> don’t need a closing tag.
29. What is a marquee?
A marquee is used to enable scrolling text in a web page. To do this, just place whatever text you want to appear scrolling within the
30. How do you create links to sections within the same page?
Links can be created using the
<a> tag, with referencing through the use of the
# symbol. For example, we can have:
which would result in the words “BACK TO TOP” appearing on the webpage and links to a bookmark named top. We can then create a separate tag like:
somewhere on the same webpage so that the user will be linked to that place when clicking on “BACK TO TOP”.
4. CSS Questions
31. What are the possible ways to apply CSS styles to a web page?
CSS can be applied in the following three ways:
32. Explain the CSS box model.
CSS box model is made up of margins, borders, padding, and content. The box model provides a more structured way to space elements in relationship to each other in web pages. In your browser’s developer tools, the CSS box model is found at the end of the CSS section and it looks like this:
33. What is the difference between inline and block elements?
Basically, a block element will take up the whole width available, and comes with a line break before and after. Examples of block level elements are: headings (i.e <h1>), paragraphs (<p>), divisions (<div>) etc.
In contrast, inline elements take up only the space they need, and do not force line breaks. Examples of inline elements are: anchors (<a>), spans (<span>) etc.
34. What is grouping used for in CSS?
Grouping allows several elements of HTML to have the very same styles applied. It uses a single declaration and selectors and separated by commas. For example:
35. What is a Class selector and how does it differ from an ID selector?
Class selectors are used to apply style to multiple HTML elements identified with the same class. Class selectors are called within the CSS document by a ‘.’, followed by the class name, like this:
The difference between classes and ID’s is that a HTML element can accept multiple classes, but only one ID. That means ID’s are unique for HTML elements.
36. What is the difference between visibility:hidden and display:none?
Although these two properties seem similar, there is quite an important difference between the two:
37. What are CSS preprocessors and why do we use them?
CSS preprocessors convert code written in a preprocessed language like SASS or LESS into the same old CSS we’ve been using for such a long time now. The main advantages of using preprocessors are:
However, there are also some disadvantages like updating issues and debugging difficulties.
38. What are child selectors in CSS?
Child selectors represent a way of grouping (for styling) a set of elements that descend from a parent element. Example:
39. What are grid systems and why do we use them in web pages?
Grid systems are structured rules that enable content to be stacked horizontally and vertically in a consistent and sustainable way. They find heavily usage in today’s websites because they offer increased producitvity while coding, they’re versatile and ideal for responsive layouts.
40. How do we use shorthand properties and why?
Shorthand properties cannot be applied to any css property but only a few like: border, outline, padding, background etc. Shorthand properties reduce file size thus improving page load time. The trick stands for listing all property values on a single line, in a pre defined order that must be respected. An example would be:
This would be exactly the same as:
41. What is the purpose of the z-index and how is it used?
The z-index property specifies the stack order of an element within the document area (or a part of it). An element with greater stack order will always be in front of an element with a lower stack order. However, z-index only works on positioned elements (position:absolute, position:relative, or position:fixed). It can have four kind of values:
42. List some of the new CSS propertied introduced with CSS3?
The following is a list of new properties added in CSS3:
Also, other features like multiple backrounds which allows you to have two or more background in the very same selector and flexible box model which ensures that elements behave predictably when the page layout must accommodate different screen sizes and different display devices.
43. Explain what pseudo-classes are and their usage.
Pseudo clasess are used to define a special state of an element. Do note that pseudo classes are not defined in the markup. They can be used for:
44. What is the CSS selector which allows you to target every element in a web page?
Called the universal selector and signed with an asterix (*), it sets all HTML element the same styling rules as defined in the property declarations. For example:
45. What are media queries and how are they used?
A media query consists of a media type and at least one expression that limits the style sheets’ scope by using media features, such as width, height, and color. Media queries, added in CSS3, let the presentation of content be tailored to a specific range of output devices without having to change the content itself. The usage of media queries is similar to this:
46. Define event bubbling.
You can do it like this:
this is used to refer to the current object in the code. In the global execution context (outside of any function),
this refers to the global object, whether in strict mode or not.
50. What is event delegation and how does it work?
Event delegation allows us to avoid adding event listeners to specific nodes of the DOM; instead, the event listener is added to one parent. Using event delegation it’s possible to add an event handler to an element, wait for an event to bubble up from a child element and easily determine from which element the event originated.
51. What is the difference between window.onload and onDocumentReady?
window.onload event will not trigger until every single element on the page has been fully loaded, including CSS, images and/or other assets. The main disadvantage is that it might take a while before any code is actually executed. On the other hand,
onDocumentReady executes code as soon as DOM is loaded.
An anonymous function is a function declared without any named identifier and in general, is not accessible after its declaration.
54. Explain the role of break and continue statements.
55. How are object properties assigned in JS?
Similar to the way a value is assigned to a variable, we assign object properties like this for example:
56. What is the difference between undeclared and undefined variables?
57. What would be the result of 5+2+”3″?
Since 5 and 2 are integers (data type) they will be added together numerically. And since “3” is a string, the result would be a concatination, meaning 73.
There are three main ways to do this:
Namespacing is used for grouping functions, variables etc. under a unique name. It is a name that has been attached to the desired functions, objects and properties. This enables code reuse and improves modularity in the coding.
A clouse resembles an object. It gets instatiated whenever you call a function. The scope of a closure is lexical, meaning everything contained within the function in which the closure belongs to, has access to any variable that is in it. A decent example would be:
wcg() creates a local variable name and then a function called
displayMessage() is an inner function that is defined inside
wcg() and is only available within the body of that function.
displayMessage() has no local variables of its own, however it has access to the variables of outer functions and so can use the variable name declared in the parent function.
6. jQuery Questions
62. What is $() in jQuery?
$() function is an alias of
$() function is used to wrap any object into jQuery object, which then allows you to call various method defined in the jQuery object.
63. What are jQuery events?
Events are actions performed on specific conditions.. When we perform these actions on an HTML page, we can do whatever we want. We then use event handlers to perform the action. Some important handlers are for example:
64. What is called chaining?
Chaining is used to connect multiple events and functions in a selector. It means specifying multiple functions and/or selectors to an element.
65. What is the difference between event.PreventDefault and event.stopPropagation?
preventDefault(): Stops the default action of an element from happening.
event.stopPropagation(): Prevents the event from bubbling up the DOM tree, thus preventing any parent handlers from being notified of the event.
66. How can we hide an image on a button click using jQuery?
We can have a click handler and then the
hide method applied to the image:
67. What is AJAX in jQuery?
68. What Is the Format of an AJAX Request?
An AJAX request can be in any of the following formats:
69. How can you find out that an AJAX request has been completed?
We can use the ReadyState property to check whether AJAX request has been completed. If the property is equal to 4, the request has been completed and data is now available.
70. Do AJAX requests retain PHP session info, when calling multiple times?
Yes, PHP retains the session info over multiple ajax calls. The duration of the php session depends on SESSION configuration.
7. PHP Questions
71. How can a file be included to a PHP page?
Two functions can be used to include a file:
require(). The file path shall be given as the parameter in both cases. For example
72. What is the difference between ‘echo’ and ‘print’ in PHP?
Although almost everyone thinks both of these functions are the same, there are some slight differences to consider:
73. What is a final class? What about a final method?
final concept of classes and methods do also exist in other programming languages like Java, and in PHP the explanation is similar:
74. How can we create a session in PHP? How do we set and unset values in sessions?
PHP provides the following to work with sessions:
75. How would you connect to MySQL database from a PHP script?
mysql_connect() function we can connect to a MySQL database like so:
76. What are the main differences between GET, POST and REQUEST methods?
GET and POST are used to send information from client browser to web server. In case of GET the information is send via GET method in name/value pair and is URL encoded. The default GET has a limit of 512 characters. The POST method transfers the information via HTTP Headers. The POST method does not have any restriction in data size to be sent. POST is used for sending data securely and ASCII and binary type’s data. The $_REQUEST contains the content of both
77. How can we find the length of a string in PHP? What about the length of an array?
PHP provides the
strlen() function to find the length of a string and
count() function for finding the array length.
78. What is an associative array?
Associative arrays are arrays that use named keys that you assign to them. An example would be:
79. Can we send e-mail using PHP? How?
Yes, we can send e-mails in PHP using the
mail() function. This function accepts 5 parameters from which 2 are optional. Example:
80. How is a constant defined in PHP?
We can define a constant using the
81. What encryption techniques are there in PHP?
There are two encryption techniques widely used in PHP:
82. Is it possible to extend the execution time of a PHP script?
Yes, that can be achieved using the
set_time_limit(int seconds) which enables us to extend the execution time of a php script. Note that the default limit is 30 seconds.
83. What is the use of header() function in PHP?
header() function sends a raw HTTP header to a client browser. This function must be called before sending the actual output.
84. How is the ternary conditional operator used in PHP?
The ternary conditional operator is used just like in most languages:
Three expressions go into this kind of assignment, the condition and two operands describing what should be executed when the condition is true or false.
85. How can we create a text file using PHP?
Most programming languages like C and Java let you create files. In PHP, the way we create files is:
This is it. The file is created, and we’ve even granted access to write in it. Additionaly, we can check if the file can be opened:
After writing or reading from file, we can close the file.
This content was originally published here.