Unit 1 - Practice Quiz

INT219 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What is the purpose of the <!DOCTYPE html> declaration at the beginning of an HTML file?

HTML document structure Easy
A. To link an external CSS file.
B. To define a section of JavaScript code.
C. To create the main heading of the page.
D. To inform the browser which version of HTML is being used.

2 Which HTML element contains all the visible content of a web page, such as headings, paragraphs, and images?

HTML document structure Easy
A. <head>
B. <body>
C. <title>
D. <html>

3 Which semantic HTML element should be used to wrap the primary, unique content of a webpage?

Semantic HTML elements Easy
A. <div>
B. <main>
C. <body>
D. <section>

4 Which HTML element is used to define a footer for a document or section, typically containing authorship, copyright, or contact information?

Semantic HTML elements Easy
A. <end>
B. <footer>
C. <header>
D. <bottom>

5 Which <input> type attribute creates a button that, when clicked, submits the form data?

Forms and input controls Easy
A. type="button"
B. type="click"
C. type="submit"
D. type="send"

6 What is the primary purpose of the <label> element in an HTML form?

Forms and input controls Easy
A. To create a container for multiple input fields.
B. To provide a caption for a form control, improving accessibility.
C. To apply CSS styles to the input field.
D. To validate the input data before submission.

7 Which HTML tag is used to embed an image in a web page?

Multimedia elements Easy
A. <src>
B. <img>
C. <picture>
D. <image>

8 In the <video> tag, which attribute is used to specify the path or URL of the video file?

Multimedia elements Easy
A. href
B. src
C. source
D. link

9 What is the correct HTML for referring to an external style sheet called styles.css?

CSS fundamentals Easy
A. <link type="text/css" src="styles.css">
B. <link rel="stylesheet" href="styles.css">
C. <style src="styles.css">
D. <stylesheet>styles.css</stylesheet>

10 Which of the following represents the correct basic syntax for a CSS rule?

CSS fundamentals Easy
A. selector ( property: value; )
B. <selector> { property: value; } </selector>
C. selector { property: value; }
D. property: value { selector; }

11 Which CSS selector would you use to select an HTML element with the attribute id="main-title"?

Selectors and specificity Easy
A. main-title
B. .main-title
C. #main-title
D. *main-title

12 Which selector is used to select all <p> elements on a page?

Selectors and specificity Easy
A. Element selector (e.g., p)
B. ID selector (e.g., #p)
C. Universal selector (e.g., *p)
D. Class selector (e.g., .p)

13 In the CSS box model, what is the term for the transparent area around an element that separates it from other elements?

Box model Easy
A. Border
B. Content
C. Padding
D. Margin

14 What are the four components of the standard CSS box model, listed from the innermost to the outermost?

Box model Easy
A. Content, Padding, Border, Margin
B. Margin, Border, Padding, Content
C. Content, Border, Padding, Margin
D. Padding, Content, Border, Margin

15 Which display property value makes an element not appear on the page at all?

Positioning and display properties Easy
A. block
B. hidden
C. inline
D. none

16 What is the default value for the position property in CSS for all elements?

Positioning and display properties Easy
A. fixed
B. absolute
C. static
D. relative

17 Which CSS property and value must be applied to a parent element to make its direct children become flex items?

Flexbox and Grid basics Easy
A. layout: flex;
B. flexbox: true;
C. position: flex;
D. display: flex;

18 In responsive web design, what is the primary purpose of CSS @media rules?

Responsive design principles Easy
A. To embed video or audio files into the page.
B. To animate CSS properties over time.
C. To import other stylesheets into the current one.
D. To apply different CSS styles for different device characteristics, like screen width.

19 In the CSS preprocessor Sass (SCSS syntax), which character is used to denote a variable?

Introduction to modern CSS workflows Easy
A. @ (At sign)
B. $ (Dollar sign)
C. # (Hash sign)
D. & (Ampersand)

20 Which Git command is used to record snapshots of the staged changes to the project's history?

Version control fundamentals using Git and GitHub Easy
A. git status
B. git push
C. git add
D. git commit

21 A developer wants to link a stylesheet and an external JavaScript file to their HTML document. For optimal performance, where should the <link> tag for the CSS and the <script> tag for the JavaScript be placed?

HTML document structure Medium
A. <script> in the <head> and <link> just before the closing </body> tag.
B. Both <link> and <script> just before the closing </body> tag.
C. Both <link> and <script> in the <head>.
D. <link> in the <head> and <script> just before the closing </body> tag.

22 Which of the following best describes the appropriate use case for the <article> element versus the <section> element in HTML5?

Semantic HTML elements Medium
A. <article> must always be placed inside a <section>, and it represents a comment or a forum post.
B. Both elements are interchangeable and are only used to improve SEO.
C. <section> is for a standalone piece of content, and <article> is used to break up that content into thematic parts.
D. <article> is for self-contained, distributable content like a blog post, while <section> is for grouping related content within a document.

23 You are building a webpage layout that includes a main title, a set of primary navigation links, the main content, and a footer with copyright information. Which combination of semantic elements is most appropriate for structuring this page?

Semantic HTML elements Medium
A. <h1>, <menu>, <content>, <p>.
B. <header>, <nav>, <main>, <footer>.
C. <header>, <ul>, <section>, <footer>.
D. <div> for the header, <ul> for navigation, <div> for content, <div> for the footer.

24 A developer wants to create a password input field that requires the password to be at least 8 characters long, contain at least one number, one uppercase letter, and one lowercase letter. Which HTML5 attribute is best suited for enforcing this complex rule on the client-side without using JavaScript?

Forms and input controls Medium
A. pattern="(?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{8,}"
B. required
C. minlength="8"
D. pattern="[a-zA-Z0-9]{8,}"

25 What is the correct way to semantically group a set of related form controls (e.g., several radio buttons for a single question) and provide a caption for that group?

Forms and input controls Medium
A. Wrap the controls in a <section> and use an <h3> for the caption.
B. Wrap the controls in a <div> and use a <span> for the caption.
C. Wrap the controls in a <ul> and use an <li> for each control, with the caption in a separate <p> tag above the list.
D. Wrap the controls in a <fieldset> and use a <legend> as the first child for the caption.

26 You are embedding a video using the <video> tag and want to ensure maximum compatibility. You have the video in MP4 and WebM formats. How should you structure the HTML to allow the browser to choose the best format it supports, and also provide a fallback for older browsers?

Multimedia elements Medium
A. <video src="video.mp4" src="video.webm">Your browser does not support the video tag.</video>
B. <video src="video.mp4" alt="video.webm">Your browser does not support the video tag.</video>
C. <video><source src="video.mp4" type="video/mp4"><source src="video.webm" type="video/webm">Your browser does not support the video tag.</video>
D. <video><source="video.mp4"><source="video.webm">Your browser does not support the video tag.</video>

27 Consider the following CSS rules applied to the same <h1> element. Which color will the <h1> element be, and why?
css
/ style.css /
h1 { color: blue !important; }
h1 { color: green; }

html
<!-- index.html -->
<h1 style="color: red;">Title</h1>

CSS fundamentals Medium
A. Green, because it is the last rule declared in the external stylesheet.
B. Red, because inline styles have the highest specificity.
C. The color will be black (browser default) because the rules are conflicting.
D. Blue, because the !important rule overrides all other origins and specificities.

28 Given the selector body #content .main p:first-child, what is its specificity value calculated in the format (IDs, Classes/Attributes, Elements)?

Selectors and specificity Medium
A. (1, 1, 2)
B. (1, 2, 1)
C. (0, 1, 3)
D. (1, 2, 2)

29 Which style will be applied to the paragraph element in the following HTML snippet?
html
<div id="container">
<p class="text highlight">This is a paragraph.</p>
</div>

css
#container p.text { color: blue; }
div p.highlight { color: red; }
p.text.highlight { color: green; }

Selectors and specificity Medium
A. green
B. Browser default color
C. blue
D. red

30 An element has the following CSS properties. What will be its total rendered width in the browser?
css
.box {
width: 200px;
padding: 20px;
border: 5px solid black;
margin: 10px;
box-sizing: border-box;
}

Box model Medium
A. 250px
B. 270px
C. 210px
D. 200px

31 Consider two adjacent block-level elements, .box1 and .box2. .box1 has margin-bottom: 30px; and .box2 has margin-top: 20px;. Assuming no other styles interfere, what will be the vertical space between these two elements?

Box model Medium
A. 10px, the difference between the two margins.
B. 30px, the larger of the two margins.
C. 20px, the smaller of the two margins.
D. 50px, the sum of both margins.

32 An element with position: absolute; is placed inside a container. How is the positioning of this absolute element determined?

Positioning and display properties Medium
A. It is always positioned relative to the <body> element.
B. It is removed from the normal document flow and positioned relative to the top-left corner of the browser viewport.
C. It is positioned relative to its nearest ancestor element that has a position value other than static.
D. It is positioned relative to its direct parent element, regardless of the parent's position property.

33 What is the primary difference between an element with display: inline-block; and an element with display: inline;?

Positioning and display properties Medium
A. inline elements respect margin-top and margin-bottom, while inline-block elements do not.
B. inline-block elements can have a width and height, while inline elements cannot.
C. There is no functional difference; inline-block is just a newer syntax.
D. inline-block elements start on a new line, while inline elements do not.

34 You have a flex container with three items. You want the items to be spaced out evenly, with the first item at the start edge and the last item at the end edge. Which justify-content value should you use?
html
<div class="container">
<div>1</div>
<div>2</div>
<div>3</div>
</div>

Flexbox and Grid basics Medium
A. justify-content: center;
B. justify-content: space-between;
C. justify-content: space-evenly;
D. justify-content: space-around;

35 In CSS Grid Layout, what is the primary advantage of using the fr unit for defining track sizes compared to using percentages?

Flexbox and Grid basics Medium
A. The fr unit can only be used for columns, while percentages can be used for both rows and columns.
B. Percentages always account for grid gaps automatically, while the fr unit does not.
C. The fr unit distributes the remaining available space, after accounting for fixed-size tracks and grid gaps, making it more flexible.
D. The fr unit is an absolute unit, making layouts more predictable.

36 Which CSS media query will apply styles ONLY when the browser viewport's width is between 600 pixels and 900 pixels, inclusive?

Responsive design principles Medium
A. @media screen and (min-width: 600px) and (max-width: 900px)
B. @media (min-width: 601px) and (max-width: 899px)
C. @media (width >= 600px) and (width <= 900px)
D. @media screen (600px < width < 900px)

37 When developing a responsive website, what is the core principle of the "mobile-first" approach?

Responsive design principles Medium
A. Creating two separate websites, one for mobile (m.domain.com) and one for desktop.
B. Writing the base CSS for mobile devices first, and then using min-width media queries to add or adapt styles for larger screens.
C. Writing all CSS within a single @media (max-width: 480px) rule to prioritize mobile styles.
D. Designing the desktop version first and then using media queries to scale it down for mobile devices.

38 What is a key benefit of using a CSS preprocessor like Sass/SCSS?

Introduction to modern CSS workflows Medium
A. It is the only way to use modern CSS features like Flexbox and Grid in older browsers.
B. It introduces features like variables, nesting, mixins, and functions, which are compiled into standard CSS, making stylesheets more maintainable and organized.
C. It allows you to write CSS rules directly inside your HTML elements without a <style> tag.
D. It automatically adds vendor prefixes for all CSS properties, ensuring perfect browser compatibility without any configuration.

39 A developer runs git fetch origin in their local repository. What is the result of this command?

Version control fundamentals using Git and GitHub Medium
A. It downloads the latest changes from the origin remote and immediately merges them into the current working branch.
B. It uploads the local commits to the origin remote.
C. It downloads the latest changes and metadata from the origin remote but does not merge them into any local branches.
D. It only checks if there are new changes on the origin remote but does not download them.

40 What is the primary purpose of a .gitignore file in a Git repository?

Version control fundamentals using Git and GitHub Medium
A. To specify files and directories that Git should intentionally not track or show in git status.
B. To store a list of Git commands that should be ignored by the current repository.
C. To hide files from other collaborators when they clone the repository.
D. To list files that are corrupted and should be ignored by the compiler.

41 Given the following CSS, which rule will apply to the span element?

html
<div id="container" class="box">
<p class="content text">
<span>Hello World</span>
</p>
</div>


css
#container :where(p.content) span { color: red; } / Rule A /
div.box p.text span { color: blue; } / Rule B /
div p span { color: green; } / Rule C /
:is(div#container) p > span { color: orange; } / Rule D /

Selectors and specificity Hard
A. Rule B (blue)
B. Rule C (green)
C. Rule A (red)
D. Rule D (orange)

42 Consider the following HTML and CSS. Why does the z-index on the .red-box have no effect, causing it to appear behind the .green-box?

html
<div class="blue-box"></div>
<div class="red-box"></div>
<div class="green-box"></div>


css
.blue-box { position: absolute; top: 0; left: 0; width: 100px; height: 100px; background: blue; z-index: 1; }
.red-box { top: 20px; left: 20px; width: 100px; height: 100px; background: red; z-index: 999; }
.green-box { position: absolute; top: 40px; left: 40px; width: 100px; height: 100px; background: green; z-index: 2; }

Positioning and display properties Hard
A. Because the z-index of 999 is an invalid value and is ignored by the browser.
B. Because .red-box lacks a position property other than static, a new stacking context is not created for it.
C. Because z-index only works on flex or grid items, not on block-level elements.
D. Because the .red-box appears before the .green-box in the document flow, it is naturally rendered behind it.

43 In CSS Grid, what is the key difference in behavior between repeat(auto-fill, minmax(100px, 1fr)) and repeat(auto-fit, minmax(100px, 1fr)) when the container has more space than the sum of the minimum widths of its items?

Flexbox and Grid basics Hard
A. auto-fill will expand the grid items to fill the remaining space, while auto-fit will leave the space empty.
B. auto-fit collapses empty tracks to zero size, causing filled tracks to grow, whereas auto-fill preserves the space for empty tracks.
C. auto-fit will expand the grid items to fill the remaining space, while auto-fill will leave the space empty, potentially creating empty tracks.
D. There is no functional difference; auto-fit is an alias for auto-fill for backward compatibility.

44 You are on a feature branch feat/new-login that diverged from the main branch several commits ago. The main branch has also received new commits. You want to incorporate the latest changes from main into your feature branch, creating a clean, linear history without a merge commit. Which command sequence should you use?

Version control fundamentals using Git and GitHub Hard
A. git checkout feat/new-login followed by git merge main
B. git checkout feat/new-login followed by git rebase main
C. git checkout main followed by git rebase feat/new-login
D. git checkout feat/new-login followed by git pull origin main

45 An <input type="submit"> button is located outside of its associated <form> element in the DOM. How can you make this button submit the form correctly without using JavaScript?

html
<form id="user-profile" action="/update">
<label>Name: <input type="text" name="username"></label>
</form>

<!-- ... other html ... -->

<input type="submit" value="Update Profile"> <!-- This button -->

Forms and input controls Hard
A. This is not possible without JavaScript; the button must be a descendant of the form.
B. Use the formaction="/update" attribute on the submit input.
C. Wrap both the <form> and the <input> in a parent <fieldset> element.
D. Add the form="user-profile" attribute to the submit input.

46 Consider two adjacent sibling block elements. The first has a margin-bottom of 20px and the second has a margin-top of 30px. A third element with clear: both and height: 0 is placed between them. What will be the resulting vertical space between the first and second elements?

Box model Hard
A. 0px, because clear: both removes all vertical margins.
B. 20px, because the clearing element's height is zero.
C. 30px, because margins still collapse despite the clearing element.
D. 50px, because clearance prevents margin collapse.

47 You are building a blog post page. The page contains the main article, a sidebar with related links, and a comments section. According to modern HTML5 semantics and accessibility best practices, what is the most appropriate nesting structure?

Semantic HTML elements Hard
A. <main> containing three <section> elements: one for the article, one for the sidebar, and one for comments.
B. <section> containing an <article>, another <section> for the sidebar, and a final <section> for comments.
C. <article> containing a <main>, a <nav> for the sidebar, and a <div> for the comments.
D. <main> containing an <article>, an <aside> for the sidebar, and a <section> for the comments.

48 In the CSS cascade, what is the correct order of precedence for rule origins, from highest to lowest, assuming all rules have the same specificity and are targeting the same element?

CSS fundamentals Hard
A. User !important > Author !important > User Agent !important > CSS Animations > Transition declarations > Author normal > User normal > User Agent normal
B. Transition declarations > User Agent !important > Author !important > User !important > CSS Animations > Author normal > User normal > User Agent normal
C. Author !important > User !important > User Agent !important > Author normal > User normal > User Agent normal > Transitions/Animations
D. Transition declarations > Author !important > User !important > User Agent !important > CSS Animations > Author normal > User normal > User Agent normal

49 You have two external JavaScript files. library.js is a large dependency, and app.js depends on library.js. You want to load them without blocking the initial page render, but ensure library.js executes before app.js. Which of the following is the most reliable and performant approach?

HTML document structure Hard
A. <script src="app.js" defer></script> followed by <script src="library.js" defer></script>
B. Both scripts with async. Use an onload event in app.js to wait for library.js.
C. <script src="library.js" async></script> followed by <script src="app.js" async></script>
D. <script src="library.js" defer></script> followed by <script src="app.js" defer></script>

50 What is the calculated font-size of the <span> element given the following CSS, assuming the root font-size is 16px and the viewport width is 1000px?

html
<div>
<p>
<span>Text</span>
</p>
</div>


css
:root { font-size: 16px; }
div { font-size: 1.25rem; } / 1.25 16px = 20px */
p { font-size: clamp(0.8em, 2vw, 2em); }
span { font-size: 1.5em; }

Responsive design principles Hard
A. 32px
B. 30px
C. 40px
D. 24px

51 A flex container has three items, each with flex: 1 2 200px;. The container's width is 500px. What will be the final width of each item?

Flexbox and Grid basics Hard
A. Each item will be 200px.
B. Each item will be 100px.
C. Each item will be 166.67px.
D. Each item will be 150px.

52 You are using the <picture> element to serve responsive images. The browser has a viewport width of 400px and supports the WebP format. Which image will be rendered based on the following code?

html
<picture>
<source srcset="img-large.webp" media="(min-width: 800px)" type="image/webp">
<source srcset="img-small.webp" media="(min-width: 400px)" type="image/webp">
<source srcset="img-small.jpg" media="(min-width: 400px)">
<img src="fallback.jpg" alt="description">
</picture>

Multimedia elements Hard
A. img-small.jpg
B. fallback.jpg
C. img-small.webp
D. img-large.webp

53 In a modern CSS workflow using Sass (SCSS), what is the fundamental difference in the generated CSS between using @extend and a @mixin?

Introduction to modern CSS workflows Hard
A. @extend can only be used with class selectors, whereas @mixin can be used with any selector.
B. @mixin compiles faster than @extend because it avoids complex selector grouping.
C. @mixin is used for static blocks of code, while @extend can accept arguments to generate dynamic styles.
D. @extend groups selectors that share the same rules, leading to less CSS repetition, while @mixin duplicates the rules for each selector where it's included.

54 A commit A containing a bug was accidentally merged into the develop branch. Several other commits (B, C, D) have been added on top of it. You cannot simply revert the merge commit because other valid changes were included. What is the most appropriate Git command to undo the specific changes from commit A while keeping the changes from B, C, and D?

Version control fundamentals using Git and GitHub Hard
A. git rebase -i A~1 and drop commit A
B. git reset --hard A~1
C. git revert A
D. git cherry-pick A..D onto a new branch

55 An element is styled with box-sizing: border-box;, width: 100px;, padding: 10px;, border: 5px solid black; and margin: 20px;. What is the total width occupied by this element in the layout, from the outer edge of its left margin to the outer edge of its right margin?

Box model Hard
A. 150px
B. 130px
C. 100px
D. 140px

56 An element is styled with position: sticky; top: 20px;. This element is inside a container which has overflow: hidden;. What will be the behavior of the sticky element as the user scrolls the page?

Positioning and display properties Hard
A. It will not stick at all, and will scroll with its container as if it were position: static.
B. It will stick 20px from the top of the viewport as intended.
C. It will only stick until it reaches the bottom edge of its parent container.
D. It will stick 20px from the top of its parent container, not the viewport.

57 When would it be appropriate to use role="application" on a part of your webpage, and what is a major accessibility risk associated with it?

Semantic HTML elements Hard
A. When embedding multimedia content, but it risks causing performance issues on mobile devices.
B. When creating a simple content-based website, to improve screen reader performance.
C. On any form with complex controls, as it automatically adds ARIA labels to all inputs.
D. When creating a web component that mimics a desktop application, but it risks disabling standard screen reader navigation commands.

58 What is the specificity of the selector nav[data-version="3.0"] > ul.main-nav > li:nth-child(2n+1)::before?

Selectors and specificity Hard
A. (0, 3, 3)
B. (0, 3, 4)
C. (0, 4, 3)
D. (1, 3, 3)

59 A form uses a custom validation message with the JavaScript setCustomValidity() method. After an invalid submission attempt, the user corrects the input. On the next submission attempt, the form still fails to submit. What is the most likely cause of this issue?

Forms and input controls Hard
A. The custom message can only be cleared by a full page reload.
B. The novalidate attribute must be added to the form to allow custom validation messages.
C. The developer did not call setCustomValidity('') on a subsequent input or change event to clear the custom error.
D. The browser's built-in validation is conflicting with the custom message, requiring event.preventDefault().

60 What is the primary purpose of the rel="preconnect" link relation type in the <head> of an HTML document, and how does it differ from rel="dns-prefetch"?

HTML document structure Hard
A. preconnect downloads and caches a resource before it's needed, whereas dns-prefetch only performs a DNS lookup.
B. dns-prefetch is a newer, more efficient version of preconnect that has replaced it in modern browsers.
C. preconnect initiates a full connection (DNS, TCP, TLS) to an origin without sending an HTTP request, whereas dns-prefetch only resolves the domain name.
D. preconnect is used for fetching API data, while dns-prefetch is specifically for image assets.