HTML5 Developer Interview Questions For 3 Years Of Experience
1.
What is the use of aria hidden attribute
The aria-hidden attribute is an accessibility attribute in HTML that is used to indicate whether an element and its contents should be visible or hidden to assistive technologies, such as screen readers. This can improve the experience for assistive technology users by hiding:-
1) Purely decorative content, such as icons or images
2) Duplicated content, such as repeated text
3) Offscreen or collapsed content, such as menus
According to the fourth rule of ARIA, aria-hidden="true" should not be used on a focusable element. Additionally, since this attribute is inherited by an element's children, it should not be added onto the parent or ancestor of a focusable element.
Using aria-hidden="false" will not re-expose the element to assistive technology if any of its parents specify aria-hidden="true".
Here's an example of how to use the aria-hidden attribute:
<div aria-hidden="true">
This content is visually hidden but accessible to assistive technologies.
</div>
2.
For accessibility which screen reader is used for which browser
1)JAWS - most compatible with Chrome , firefox and Internet explorer although it supports other browsers as well. It is expensive. Compatible only with windows OS. JAWS came in the market much before NVDA and is a slightly better as compared to NVDA for blind uers because of better braille support , more sounds and whistles and more configuration options. But still it's a better deal to use a free NVDA than to pay a heavy price for JAWS. Hence the users have now been shifting to NVDA and popularity of JAWS is decreasing.
2) NVDA- most compatible with Chrome , firefox and Edge although it supports other browsers as well. It is free of cost. Compatible only with windows OS
3)Voiceover- Available and used by default with Macos(Mac laptops) and IOS(Iphones)
4)Talkback - Available and used by default with Android phones
3.
What are web workers
Web Workers are a browser feature that allows you to run JavaScript code in the background, separate from the main browser thread. They enable concurrent execution and help prevent blocking the user interface during computationally intensive or time-consuming tasks.
Here are some key points about web workers:
1. Background Execution: Web Workers allow you to run scripts in the background without blocking the main thread. This keeps the user interface responsive and improves overall performance.
2. Separate Thread: Web Workers run in a separate thread from the main JavaScript thread, often referred to as the "worker thread." This thread is isolated and doesn't share the same memory space as the main thread.
3. Communication: Web Workers communicate with the main thread using messaging. They can receive messages from the main thread and post messages back to it. This messaging system allows data exchange and coordination between the worker and the main thread.
4. Limited Scope: Web Workers have limited access to browser APIs and the DOM. They can't directly manipulate the DOM or access certain objects and methods available in the main thread. This limitation helps maintain security and prevents worker threads from interfering with the user interface.
5. Types of Web Workers: There are two types of web workers: dedicated workers and shared workers. Dedicated workers are tied to a specific script and can communicate only with the script that created them. Shared workers can be accessed by multiple scripts or web pages running on the same origin, allowing them to share data and communicate with multiple sources.
Web Workers are useful for various tasks such as heavy computations, parsing large datasets, performing complex algorithms, and offloading non-UI tasks. They can help improve the overall responsiveness and performance of web applications by distributing the workload across multiple threads.
Here's a simple example of using a web worker:
In this example, the main thread creates a web worker using the `Worker` constructor, specifying the script file (`worker.js`). The main thread sends a message to the web worker using `worker.postMessage()`. The web worker receives the message in its `onmessage` event handler, logs it, and sends a response back to the main thread using `self.postMessage()`. The main thread receives the response in its `onmessage` event handler and logs it.
Web Workers are supported in modern browsers and provide a powerful tool for performing background tasks, improving performance, and enhancing the user experience of web applications.
// main.js (main thread)
const worker = new Worker('worker.js');
worker.onmessage = function(event) {
console.log('Message from web worker:', event.data);
};
worker.postMessage('Hello from main thread!');
// worker.js (worker thread)
self.onmessage = function(event) {
console.log('Message from main thread:', event.data);
self.postMessage('Hello from web worker!');
};
4.
Which html elements were used before HTML5 for embedding video into the website
Before HTML5, in order to have a video play on a webpage, you would need to use a plugin like Adobe Flash Player. With the introduction of HTML5, you can now place videos directly into the page itself.
The HTML5 <video> element is used to embed video in web documents. It may contain one or more video sources, represented using the src attribute or the source element.
To embed a video file, just add this code snippet and change the src to the path of your video file:
<video controls>
<source src="test.ogg" type="video /ogg">
<source src="test.mp4" type="video /mpeg">
Your browser does not support the video element. Kindly update it to latest version.
</video>
5.
Some important points related to accessibility
Accessibility is an essential aspect of web development, ensuring that websites and applications are usable by people with disabilities. Here are some important points related to accessibility:
1. Semantic HTML: Use appropriate HTML tags to convey the structure and meaning of the content. Use headings (`<h1>` to `<h6>`) to organize content, `<p>` for paragraphs, `<nav>` for navigation sections, `<button>` for interactive buttons, etc. This helps screen readers and assistive technologies understand the content and provide a better experience for users.
2. Keyboard Accessibility: Ensure that all functionality can be accessed and operated using a keyboard alone. This is crucial for people with motor disabilities who rely on keyboard navigation. Make sure focus is properly managed and visible, and elements such as buttons, links, and form inputs are keyboard accessible and provide appropriate feedback.
3. Alt Text for Images: Provide descriptive alternative text (`alt` attribute) for images. This allows screen readers to describe the content of images to visually impaired users. Use concise and meaningful descriptions that convey the purpose or information conveyed by the image.
4. Contrast and Color: Use sufficient contrast between text and background colors to ensure readability. Low contrast can make it difficult for people with visual impairments or color blindness to read content. Consider using tools to check contrast ratios and ensure compliance with accessibility standards.
5. Forms and Labels: Use proper form elements and labels to provide clear instructions and associations. Associate labels with form inputs using the `for` attribute or by wrapping the input within the label element. This helps screen readers understand the purpose of form inputs and improves usability for users with visual impairments.
6. Focus Indicators: Ensure that focus indicators are clearly visible and distinguishable. When users navigate through a page using the keyboard, it's important to provide a visual indication of the focused element. This helps users with disabilities understand their location within the page and improves overall navigation.
7. ARIA Roles and Attributes: Use ARIA (Accessible Rich Internet Applications) roles and attributes to enhance the accessibility of complex or custom UI components. ARIA attributes provide additional information to assistive technologies, helping them understand and navigate interactive elements like menus, tabs, and modals.
8. Responsive and Mobile Accessibility: Ensure that your website is responsive and works well on different devices and screen sizes. Consider the needs of users with disabilities who may access your site using mobile devices or assistive technologies. Test your site's accessibility on mobile devices and use media queries to adapt the layout and design.
9. Testing and Auditing: Regularly test and audit your website for accessibility. Use automated accessibility testing tools to identify common issues, and perform manual testing to understand the experience from the perspective of users with disabilities. Incorporate accessibility into your development process to catch and address issues early on.
10. Continuous Learning: Stay updated with accessibility guidelines and best practices. Accessibility standards and techniques evolve, so it's important to continuously learn and improve your understanding of accessibility to create inclusive and usable experiences for all users.
These points highlight some important considerations for creating accessible websites and applications. By following accessibility best practices, you can ensure that your content is available and usable by a wider range of users, regardless of their abilities or disabilities.
The WCAG 2.0 is organized in three different levels:
Level A: the most basic Web accessibility features;
Level AA: the most common barriers for disabled people;
Level AAA: the highest level of accessibility.
Even level A is just the beginning, and the level AA embraced on large companies’ websites, the level AAA is the one to which is hoping that someday all the Web products will go. For reaching those, it’s very important to have empathy for your users, they need to have excellent experiences on the Web, too.
6.
What is view state and session state
ViewState:
It is maintained at only one level that is page-level. Changes made on a single page is not visible on other pages. Information that is gathered in view state is stored for the clients only and cannot be transferred to any other place. View state is synonymous with serializable data only.
ViewState has a tendency for the persistence of page-instance-specific data. When view state is used, the values posted of a particular page persist in the browse area that the client is using and post back only when the entire operation is done. The data of the previous page is no longer available when another page is loaded. Also, Data is not secure in this case because it is exposed to clients. Encryption can be used for data security.
SessionState:
It is maintained at session-level and data can be accessed across all pages in the web application. The information is stored within the server and can be accessed by any person that has access to the server where the information is stored.
SessionState has the tendency for the persistence of user-specific data and is maintained on the server-side. This data remains available until the time that the session is completed or the browser is closed by the user. The session state is only valid for type objects.
7.
What should be preferred for storing tokens localstorage or session storage or cookies and why ?
When it comes to storing tokens, the preferred method depends on the specific use case and security requirements.
Here are some key differences between local storage, session storage, and cookies:
1) Local Storage: Data stored in local storage persists even after the user closes the browser or restarts the computer. This makes it a good choice for long-term storage of tokens or other data that needs to be accessed by the user across multiple sessions. However, since local storage data is not tied to a specific session, it may be more susceptible to certain types of attacks, such as cross-site scripting (XSS) or cross-site request forgery (CSRF).
2) Session Storage: Data stored in session storage persists only until the user closes the browser or navigates away from the website. This makes it a good choice for short-term storage of tokens or other data that only needs to be accessed during a single session. Since session storage data is tied to a specific session, it may be more secure than local storage against certain types of attacks.
3) Cookies: Data stored in cookies is sent to the server with every HTTP request, making it a good choice for storing tokens or other data that needs to be accessed by the server. Cookies can be configured with various security options, such as HttpOnly and Secure flags, to help protect against attacks like XSS and CSRF. However, cookies have a size limit of 4KB, and can potentially be accessed by other sites if they share the same domain or subdomain.
In general, if the token needs to be accessed by both the client and the server, it is usually best to use cookies. If the token only needs to be accessed by the client, local storage or session storage may be appropriate depending on the specific requirements. It is important to properly secure whichever method is chosen, with techniques such as encryption and validation, to protect against attacks.
8.
What is an image map
The HTML <map> tag defines an image map. An image map is an image with clickable areas. The areas are defined with one or more <area> tags.
HTML:-
For more information click here
<img src="workplace.jpg" alt="Workplace" usemap="#workmap" width="400" height="379">
<map name="workmap">
<area shape="rect" coords="34,44,270,350" alt="Computer" href="computer.htm">
<area shape="rect" coords="290,172,333,250" alt="Phone" href="phone.htm">
<area shape="circle" coords="337,300,44" alt="Cup of coffee" href="coffee.htm">
</map>
9.
what is a WebSocket ?
A websocket is basically a connection between the client and the server in a way that server can send data to the client whenever it wants without waiting for the client to make a http request.
A request to a WebSocket connection is sent to the server from a client (or multiple clients) through a process called the WebSocket handshake, which starts with the client sending a regular HTTP request to the server. Part of this request includes an Upgrade header, which indicates to the server that the the client is trying to make a WebSocket connection. This request is called a WebSocket handshake
10.
What is the difference between HTML and HTML5?
1. Multimedia Support: HTML5 provides native support for audio and video playback,
eliminating the need for third-party plugins such as Adobe Flash.
2. New Semantic Elements: HTML5 introduces new semantic elements like "header", "footer",
"nav", "section", and "article" that make it easier to structure web pages and create more
accessible and search engine friendly content.
3. Canvas Element: HTML5 includes a new "canvas" element that allows developers to draw
graphics, animations, and other visual effects using JavaScript.
4. Offline Capabilities: HTML5 introduces new APIs that allow web applications to work offline
and store data on the client-side, reducing server requests and improving user experience.
5. Improved Forms: HTML5 offers several new form elements and attributes such as "date",
"time", "search", "tel", "number", "required", and "placeholder" that make it easier to create
forms and validate user input.
Overall, HTML5 offers a more modern and feature-rich approach to web development compared to its predecessor, HTML.