




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































Question 1. Which HTML5 element is most appropriate for containing site‑wide navigation links? A) B) C) D) Answer: B Explanation: is semantically intended for major navigation blocks, helping both developers and assistive technologies identify navigation menus. **Question 2. In HTML, which element should be used to represent a self‑contained article that could be syndicated?** A) B) C) D) Answer: A Explanation: denotes independent, reusable content such as a blog post or news story, making it suitable for syndication. Question 3. Which of the following is a block‑level element by default? A) B)
C) D) Answer: C Explanation: is a block‑level element, causing it to start on a new line and take the full width available. **Question 4. When should you prefer using a over a semantic element?** A) When the content is purely decorative B) When there is no appropriate semantic tag for the content C) When you need to apply a CSS grid layout D) When the element contains only text Answer: B Explanation: is a generic container used when no specific semantic element fits the purpose of the content. **Question 5. Which heading order best follows proper hierarchical structure for accessibility?** A), , B) ,, C), , D) ,, `` Answer: C
A) type="text" B) type="tel" C) type="number" D) type="email" Answer: B Explanation: type="tel" triggers a numeric keypad optimized for phone number entry on touch devices. Question 9. To associate a with an without using the for attribute, what must be done? A) Wrap the inside the element B) Place the before the in the markup C) Add aria-label to the D) Use JavaScript to link them dynamically Answer: A Explanation: Nesting the inside the `` automatically associates them, improving usability. Question 10. Which image format typically provides the smallest file size for photographic content on the web? A) SVG B) PNG C) JPEG D) GIF
Answer: C Explanation: JPEG uses lossy compression optimized for photographs, achieving lower file sizes than PNG or GIF. **Question 11. How does the element improve responsive image delivery?** A) It allows multiple elements with media queries to select the best image variant B) It automatically compresses images in the browser C) It replaces the need for srcset attributes D) It forces all images to load at full resolution Answer: A Explanation: works with tags that specify media conditions, enabling browsers to choose the most appropriate image. Question 12. Which attribute on the `` element defines the image candidate set for different device pixel ratios? A) media B) sizes C) srcset D) type Answer: C Explanation: srcset lists image URLs with descriptors (e.g., 2x) so the browser can pick the right resolution.
B) C) D) `` Answer: C Explanation: The viewport meta tag tells browsers how to scale the page, enabling responsive layouts. Question 16. In the CSS box model, which property defines the space between the element’s border and adjacent elements? A) padding B) margin C) border D) outline Answer: B Explanation: margin creates outer spacing that separates the element from its neighbors. Question 17. Setting box-sizing: border-box; on an element changes the calculation of what? A) Width and height now include padding and border B) Only the border width is added to the content size C) Padding is ignored completely D) Margin becomes part of the element’s total width Answer: A
Explanation: With border-box, the element’s declared width/height encompass its content, padding, and border, simplifying layout math. Question 18. Which media feature checks whether the device’s screen width is at least 768 px? A) max-width: 768px B) min-width: 768px C) width: 768px D) device-width: 768px Answer: B Explanation: min-width applies the query when the viewport width meets or exceeds the specified value. Question 19. What is the primary advantage of a mobile‑first media query strategy? A) Styles are written for the largest screens first, then overridden B) It reduces the amount of CSS by eliminating media queries C) Base styles target small screens, and larger‑screen enhancements are added later, improving performance on mobile devices D) It forces all browsers to load the same CSS file regardless of device Answer: C Explanation: Mobile‑first starts with minimal CSS for small devices, then adds media queries for larger screens, ensuring faster loading on constrained networks.
B) flex-basis C) flex-shrink D) align-self Answer: C Explanation: flex-shrink specifies how much an item will shrink relative to the rest when the container is too small. Question 23. How does flex-direction: column-reverse; affect item order? A) Items are displayed in normal column order from top to bottom B) Items are displayed in a row, reversed horizontally C) Items are displayed in a column, but the visual order is reversed (last item appears first) D) It has no effect unless flex-wrap is also set Answer: C Explanation: column-reverse stacks items vertically while reversing their visual order. Question 24. In CSS Grid, what does grid-template-columns: 1fr 2fr; define? A. Two columns where the first takes one‑third and the second takes two‑third of the available space B. Two columns each 1 fr wide, with a 2 fr gap between them C. A single column that is three fractions wide D. Two columns of equal width Answer: A
Explanation: fr units divide the free space; 1fr 2fr creates a 1:2 ratio, giving the second column twice the width of the first. Question 25. Which CSS property is used to name grid lines for easier placement? A) grid-area B) grid-template-areas C) grid-column-start D) grid-template-columns with named lines (e.g., [sidebar] 200px) Answer: D Explanation: Named grid lines are defined inside grid-template-columns or grid- template-rows using brackets, allowing placement via those names. Question 26. What does the gap property control in a CSS Grid layout? A) The margin of the grid container B) The spacing between grid tracks (rows and columns) C) The padding inside each grid item D) The width of the grid border Answer: B Explanation: gap (or row-gap/column-gap) defines the space between adjacent grid tracks, simplifying gutter creation. Question 27. Which relative unit scales proportionally with the root element’s font size?
Answer: B Explanation: max-width caps the element’s width while still allowing it to shrink on smaller screens. Question 30. Which JavaScript method returns the first element that matches a CSS selector? A) document.getElementById() B) document.querySelectorAll() C) document.querySelector() D) document.getElementsByClassName() Answer: C Explanation: querySelector returns the first Element that matches the supplied selector string. Question 31. To add a CSS class named “active” to a button element stored in variable btn, which statement is correct? A) btn.addClass('active'); B) btn.classList.add('active'); C) btn.className = 'active'; D) btn.setAttribute('class', 'active'); Answer: B Explanation: classList.add appends a class without overwriting existing classes, making it the preferred method.
Question 32. Which DOM method creates a new `` element? A) document.createElement('div') B) document.newElement('div') C) document.appendChild('div') D) document.getElementById('div') Answer: A Explanation: createElement generates a new element node of the specified type. Question 33. When removing an element stored in variable item from its parent, which code is correct? A) item.remove(); B) item.delete(); C) item.parentNode.removeChild(item); D) Both A and C are valid in modern browsers Answer: D Explanation: Modern browsers support Element.remove(), and the older parentNode.removeChild also works; both achieve the same result. Question 34. Which event type is most appropriate for detecting a user resizing the browser window? A) click B) load C) resize
**Question 37. To defer script execution until after the HTML document is parsed, which attribute should be added to the `
B) That the listener should be removed after one invocation C) That the listener is passive D) That the listener should only fire on right‑clicks Answer: A Explanation: Passing true sets the listener to the capturing phase; false (default) uses bubbling. Question 40. Which JavaScript method can be used to check if an element has a specific CSS class? A) element.hasClass('name') B) element.classList.contains('name') C) element.className.includes('name') D) element.getAttribute('class') === 'name' Answer: B Explanation: classList.contains returns a Boolean indicating whether the class is present. Question 41. What is the default display value of a `` element? A) inline B) block C) flex D) none Answer: B
Question 44. Which CSS selector selects all direct child elements of a with class “menu”? A) .menu li B) .menu > li C) ul.menu li D) ul > .menu li Answer: B Explanation: The child combinator (>) selects only immediate `` children of the element with class “menu”. Question 45. In a Flex container, what does align-items: stretch; do? A) Centers items along the cross axis B) Stretches items to fill the container’s cross‑axis size (default behavior) C) Aligns items to the start of the main axis D) Prevents items from growing beyond their content size Answer: B Explanation: stretch expands flex items to match the container’s cross‑axis dimension unless a specific size is set. Question 46. Which CSS property allows you to set the order of flex items without changing the HTML source? A) flex-order B) order C) position
D) z-index Answer: B Explanation: The order property reorders flex items visually; lower values appear first. Question 47. What does grid-auto-flow: dense; accomplish? A) Forces all grid items to occupy a single row B) Packs items tightly, filling gaps left by larger items C) Makes the grid responsive to viewport changes automatically D) Disables automatic placement of items Answer: B Explanation: The dense keyword tells the grid to back‑fill empty cells with later items to reduce unused space. Question 48. Which unit is best for creating a fluid, full‑width container that never exceeds 90 % of the viewport width? A) 90vw B) 90% C) calc(90vw - 2rem) D) max-width: 90vw; width: 100%; Answer: D Explanation: Setting width: 100% makes the container fill its parent, while max- width: 90vw caps it at 90 % of the viewport, ensuring fluidity without exceeding the limit.