1.Explain the difference between cookies, sessionStorage, and localStorage.
- Cookies are small pieces of data sent from a website and stored on the user's computer.
sessionStorageandlocalStorageare part of the Web Storage API, with the former storing data for the duration of a page session and the latter persisting data even after the browser is closed.
- Cookies are small pieces of data sent from a website and stored on the user's computer.
2.What is the purpose of the
<canvas>element in HTML5, and how is it different from SVG?<canvas>is used for drawing graphics, such as charts or games, using JavaScript. Unlike SVG, which creates scalable vector graphics,<canvas>is raster-based and works with pixel data.
3.Explain the concept of responsive web design and how media queries are used.
- Responsive web design ensures that a web page adapts to different screen sizes and devices. Media queries in CSS are used to apply styles based on characteristics like screen width, height, or device orientation.
4.What is the role of the
deferandasyncattributes when loading scripts?- Both attributes affect how scripts are loaded.
deferensures that the script is executed only after the HTML is fully parsed, whileasyncallows the script to be executed asynchronously, not necessarily in order.
- Both attributes affect how scripts are loaded.
5.What are WebSockets, and how are they different from traditional HTTP connections?
- WebSockets provide a full-duplex communication channel over a single, long-lived connection. Unlike traditional HTTP, which is request-response-based, WebSockets enable real-time, bidirectional communication between the client and server.
6.How does the concept of the same-origin policy impact web security, and what are CORS headers?
- The same-origin policy restricts web pages from making requests to a different domain. CORS (Cross-Origin Resource Sharing) headers are used to relax these restrictions and allow controlled access to resources on other domains.
7.Explain the purpose of the HTML
<details>and<summary>elements.<details>is used to create a disclosure widget from which additional information can be revealed or hidden.<summary>is used to provide a visible heading for the<details>element.
8.What are ARIA roles, and how do they contribute to web accessibility?
- ARIA (Accessible Rich Internet Applications) roles are attributes that define the roles and properties of elements, helping assistive technologies understand and convey information to users with disabilities.
9.How can you optimize the performance of a web page, considering both loading time and rendering speed?
- Techniques include minimizing HTTP requests, using asynchronous loading for scripts, optimizing images, enabling compression, utilizing content delivery networks (CDNs), and employing efficient CSS and JavaScript coding practices.
10.Explain the concept of semantic HTML and its significance for SEO and accessibility.
- Semantic HTML involves using tags that carry meaning about the structure of the content. This not only improves SEO by providing search engines with better information but also enhances accessibility for users with assistive technologies.
Comments
Post a Comment