HTML & CSS Fundamentals Mastery Quiz

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Catherine Halcomb
Catherine Halcomb
Community Contributor
Quizzes Created: 3677 | Total Attempts: 6,977,842
| Questions: 30 | Updated: Sep 8, 2026
Please wait...
Question 1 / 31
🏆 Rank #--
0 %
0/100
Score 0/100

1. An element with position: static will ignore the top, right, bottom, and ______ properties.

Explanation

An element with position: static does not respond to positioning properties such as top, right, bottom, and left, which are used to adjust its placement on the page. Instead, static positioning means the element is positioned according to the normal flow of the document. Therefore, the left property, which would typically shift the element horizontally, is also ignored. This ensures that the element remains in its original position relative to surrounding elements, maintaining the default layout behavior of the document.

Submit
Please wait...
About This Quiz
HTML & CSS Fundamentals Mastery Quiz - Quiz

This assessment evaluates your understanding of HTML and CSS fundamentals. You will explore essential tags, positioning properties, and their practical applications. This knowledge is crucial for anyone looking to build and design effective web pages.

2.

What first name or nickname would you like us to use?

You may optionally provide this to label your report, leaderboard, or certificate.

2. Three nested divs: outer (position: relative) > middle (position: static) > inner (position: absolute). Relative to which div is inner positioned?

Submit

3. Two overlapping boxes in the same stacking context: #boxA { z-index: 1; } and #boxB { z-index: 2; }. Which box appears on top?

Submit

4. Given: .header { position: fixed; top: 0; width: 100%; } What happens as the user scrolls down the page?

Submit

5. The parent has position: relative. The child has: position: absolute; top: 0; right: 0; Where does the child appear?

Submit

6. Given: .box { position: absolute; top: 0; left: 0; } The parent of .box has no position set. Where does .box appear?

Submit

7. Given: .box { position: relative; top: 20px; left: 10px; } What happens to .box, and do surrounding elements fill its original spot?

Submit

8. Which CSS centers a 200px by 200px .box exactly in the middle of a relatively positioned parent?

Submit

9. What CSS declaration must be added to .container so that any child with position: absolute is positioned relative to .container?

Submit

10. Which CSS nudges a .badge 5px down and 5px to the right from its default spot without shifting surrounding elements?

Submit

11. Which CSS pins a .chat-button to the bottom-right corner of the screen (20px from each edge) so it never moves when scrolling?

Submit

12. Which CSS makes a .navbar stick to the top of the viewport as the user scrolls down the page?

Explanation

Using `position: sticky;` in CSS allows an element to behave like a relatively positioned element until it reaches a specified scroll position, at which point it becomes fixed in place. By setting `top: 0;`, the `.navbar` will stick to the top of the viewport as the user scrolls down the page, providing a consistent navigation experience. This is particularly useful for keeping navigation menus visible without taking them out of the document flow entirely, as would happen with `position: fixed;`.

Submit

13. Which CSS rule positions a .card 10px from the top and 15px from the right using absolute positioning?

Explanation

This CSS rule uses absolute positioning, which allows the element to be positioned relative to its nearest positioned ancestor. By setting `top: 10px` and `right: 15px`, the `.card` class is placed 10 pixels from the top and 15 pixels from the right of that ancestor. This precise positioning is crucial for layout design, ensuring that the card appears exactly where intended on the page, regardless of other elements. The other options either use incorrect properties or positioning methods that do not achieve the desired effect.

Submit

14. The CSS property used to control which positioned element visually sits on top of another is ______.

Explanation

The z-index property in CSS determines the stacking order of positioned elements on a web page. Elements with a higher z-index value are rendered on top of those with a lower value. This property is only effective on elements that have a position value other than static (e.g., relative, absolute, or fixed). By manipulating the z-index, developers can control which elements overlap and how they are visually presented, making it a crucial tool for layout design and ensuring the correct display of content.

Submit

15. If you set position: absolute on an element and none of its ancestors are positioned, it will be placed relative to the ______.

Explanation

When an element is set to `position: absolute`, it is removed from the normal document flow and positioned relative to its nearest positioned ancestor. If no ancestor elements have a positioning context (i.e., they are not set to `relative`, `absolute`, or `fixed`), the element will instead be positioned relative to the initial containing block, which is typically the viewport or the `` element. This means it will align itself based on the overall layout of the page rather than any specific parent element.

Submit

16. Which tag is used to define the root of an HTML document?

Explanation

The `` tag is used to define the root element of an HTML document. It serves as the container for all other elements within the page, including the `

` and `` sections. This tag indicates to the web browser that the content enclosed is written in HTML, ensuring proper rendering of the document. Without the `` tag, the browser would not recognize the structure of the HTML content, leading to potential display issues.
Submit

17. Position: sticky behaves like ______ positioning until a scroll threshold is crossed, then it behaves like ______ positioning.

Explanation

Position: sticky initially behaves like relative positioning, allowing elements to remain in their normal flow within the document. However, once the user scrolls past a defined threshold, the element switches to fixed positioning, detaching from the flow and remaining visible at a specified position in the viewport. This combination allows for dynamic layouts where elements can scroll with the page until a certain point, enhancing user experience by keeping important content accessible.

Submit

18. Position: fixed positions an element relative to the ______ (it stays put even when the page is scrolled).

Explanation

Position: fixed positions an element relative to the viewport, meaning it remains in the same spot on the screen regardless of scrolling. This allows for consistent visibility of the element, such as a navigation bar or a floating action button, enhancing user experience by keeping important controls accessible at all times. Unlike other positioning methods, fixed positioning does not depend on any ancestor elements, making it a powerful tool for web design.

Submit

19. An element with position: absolute is positioned relative to its nearest ancestor that has a position value other than ______.

Explanation

An element with `position: absolute` is positioned relative to its closest ancestor that has a positioning context, which is defined by having a position value of `relative`, `fixed`, or `sticky`. If no such ancestor exists, it defaults to positioning itself relative to the initial containing block, typically the viewport. Since `static` is the default positioning value and does not create a positioning context, an absolutely positioned element will ignore any ancestor with a `static` position, making it the correct answer.

Submit

20. To move an element relative to its normal position while keeping its original space in the page flow, you use position: ______.

Explanation

Using `position: relative` allows an element to be positioned relative to its original location in the document flow. This means that while you can adjust its position using top, right, bottom, or left properties, the space it originally occupied remains unchanged. This is useful for creating layouts where you want to shift elements without affecting the surrounding elements, maintaining the overall structure of the page.

Submit

21. The default value of the CSS `position` property is ______.

Explanation

In CSS, the default value of the `position` property is `static`. This means that elements are positioned according to the normal flow of the document, without any special positioning rules applied. When an element has a position of `static`, it does not respond to the top, right, bottom, or left properties, and it will be placed in the order it appears in the HTML. This default behavior ensures a predictable layout unless explicitly changed by using other positioning values like `relative`, `absolute`, or `fixed`.

Submit

22. Which HTML tag defines a row in a table?

Explanation

The `

` tag is used in HTML to define a row within a table. Each row can contain one or more cells, which are defined using the `` tag for standard cells or the `` tag for header cells. The `` element helps organize data into horizontal sections, making it easier to read and understand the information presented in the table format.
Submit

23. Which of the following correctly defines an unordered list with one item?

Explanation

An unordered list in HTML is defined using the `

    ` tag, which stands for "unordered list." Each item within this list is represented by the `
  • ` tag, which stands for "list item." The structure `
    • item
    ` correctly encapsulates a single item in an unordered list format, making it suitable for displaying items without a specific sequence. In contrast, the other options use incorrect or non-standard tags, making them invalid for creating an unordered list.
Submit

24. Which tag specifies the title shown on the browser tab?

Explanation

The `

` tag is used within the `` section of an HTML document to define the title of the webpage. This title is displayed on the browser tab and is also used by search engines as the clickable headline for search results. It plays a crucial role in SEO and user experience, as it provides a concise description of the page's content.
Submit

25. How do you write a comment in HTML?

Explanation

In HTML, comments are written using the syntax ``. This allows developers to include notes or explanations in the code that will not be displayed in the web browser. The comment begins with ``, effectively telling the browser to ignore any content within these markers. This feature is useful for documenting code or providing context without affecting the webpage's functionality. Other comment styles, such as those used in programming languages like JavaScript or CSS, are not applicable in HTML.

Submit

26. Which tag is used to insert an image into a webpage?

Explanation

The `` tag is used in HTML to embed images into a webpage. It allows developers to specify the source of the image through the `src` attribute, along with other attributes such as `alt` for alternative text, `width`, and `height`. This tag is essential for displaying visual content, enhancing user experience and engagement on websites. Unlike other tags listed, `` is specifically designed for image inclusion, making it the correct choice for this purpose.

Submit

27. Which tag is used to create a hyperlink in HTML?

Explanation

The `` tag in HTML is used to create hyperlinks, allowing users to click on text or images to navigate to another page or resource. The tag typically includes the `href` attribute, which specifies the URL of the destination. For example, `Visit Example` creates a clickable link that directs users to the specified website. This functionality is essential for web navigation and linking content across different pages or sites.

Submit

28. Which of the following is the correct syntax for an HTML element with an attribute?

Explanation

In HTML, an element is defined by a tag, and attributes provide additional information about that element. The correct syntax for an anchor tag includes the tag ``, followed by the attribute `href` to specify the link's destination, and the text that will be displayed as the link. Therefore, `link` correctly formats the anchor element with the `href` attribute, ensuring proper structure and functionality in HTML.

Submit

29. Which tag contains the visible content of a webpage?

Explanation

The `

` tag contains all the visible content of a webpage, including text, images, and other media that users interact with. It is part of the HTML structure and is essential for rendering the content that users see in their web browsers. In contrast, the `` section holds meta-information, links to stylesheets, and scripts, which are not displayed directly on the page. Therefore, the `` tag is crucial for the user-facing part of a website.
Submit

30. What must every HTML document begin with?

Explanation

Every HTML document must begin with the `` declaration to inform the web browser about the version of HTML being used. This declaration ensures that the document is interpreted correctly and adheres to the standards of HTML5. It helps in rendering the page consistently across different browsers, preventing potential issues with layout and functionality. Without this declaration, browsers may switch to "quirks mode," which can lead to unexpected behavior in how the content is displayed.

Submit
×
Saved
Thank you for your feedback!
View My Results
Cancel
  • All
    All (30)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
An element with position: static will ignore the top, right, bottom,...
Three nested divs: outer (position: relative) > middle (position:...
Two overlapping boxes in the same stacking context: #boxA { z-index:...
Given: .header { position: fixed; top: 0; width: 100%; } What happens...
The parent has position: relative. The child has: position: absolute;...
Given: .box { position: absolute; top: 0; left: 0; } The parent of...
Given: .box { position: relative; top: 20px; left: 10px; } What...
Which CSS centers a 200px by 200px .box exactly in the middle of a...
What CSS declaration must be added to .container so that any child...
Which CSS nudges a .badge 5px down and 5px to the right from its...
Which CSS pins a .chat-button to the bottom-right corner of the screen...
Which CSS makes a .navbar stick to the top of the viewport as the user...
Which CSS rule positions a .card 10px from the top and 15px from the...
The CSS property used to control which positioned element visually...
If you set position: absolute on an element and none of its ancestors...
Which tag is used to define the root of an HTML document?
Position: sticky behaves like ______ positioning until a scroll...
Position: fixed positions an element relative to the ______ (it stays...
An element with position: absolute is positioned relative to its...
To move an element relative to its normal position while keeping its...
The default value of the CSS `position` property is ______.
Which HTML tag defines a row in a table?
Which of the following correctly defines an unordered list with one...
Which tag specifies the title shown on the browser tab?
How do you write a comment in HTML?
Which tag is used to insert an image into a webpage?
Which tag is used to create a hyperlink in HTML?
Which of the following is the correct syntax for an HTML element with...
Which tag contains the visible content of a webpage?
What must every HTML document begin with?
play-Mute sad happy unanswered_answer up-hover down-hover success oval cancel Check box square blue
Alert!