HTML & CSS Fundamentals 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 Alfredhook3
A
Alfredhook3
Community Contributor
Quizzes Created: 5199 | Total Attempts: 3,128,428
| 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 is the default positioning for HTML elements, meaning it follows the normal document flow. In this state, the properties top, right, bottom, and left do not affect the element's placement. Instead, the element's position is determined by its order in the HTML and other layout properties like margins and padding. Therefore, the left property, which typically controls the horizontal positioning of an element, is ignored when the element is static. This ensures that static elements are positioned based solely on their natural flow in the layout.

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

This assessment evaluates your understanding of fundamental HTML and CSS concepts, including document structure, element attributes, and positioning properties. It is essential for web developers to grasp these basics to create effective and well-structured web pages. By taking this quiz, you can reinforce your knowledge and identify areas for improvement... see morein your web development skills. see less

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. What CSS declaration must be added to .container so that any child with position: absolute is positioned relative to .container?

Submit

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

Submit

10. 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

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

Submit

12. A position: sticky element is constrained to stay within the boundaries of its ______ element.

Explanation

A position: sticky element is designed to toggle between relative and fixed positioning based on the user's scroll position. It remains fixed within the boundaries of its parent or containing element, meaning that when the parent is scrolled out of view, the sticky element will also leave the viewport. This behavior ensures that the sticky element does not extend beyond its parent, maintaining a clear relationship between the two in terms of layout and visibility. Thus, the sticky element effectively remains confined within its parent or containing element.

Submit

13. 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. It allows developers to specify which elements should appear on top of others when they overlap. Elements with a higher z-index value are rendered in front of those with a lower value. This property is essential for creating layered layouts and ensuring that important content is visible, enhancing the overall user experience.

Submit

14. 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 has `position: absolute` and none of its ancestor elements are positioned (i.e., they do not have `position: relative`, `absolute`, or `fixed`), the element is positioned relative to the initial containing block. This initial containing block is typically the viewport or the `` element. As a result, the absolutely positioned element will align itself based on the dimensions and position of the viewport, rather than any parent elements.

Submit

15. For position: sticky to actually stick, you must set at least one of top, right, bottom, or ______, otherwise it behaves like relative.

Explanation

For the CSS property `position: sticky` to function correctly, at least one of the directional properties (top, right, bottom, or left) must be defined. This is because these properties determine the element's position relative to its nearest scrolling ancestor. If none are set, the element defaults to behaving like `position: relative`, meaning it won't "stick" but will instead flow with the document as it scrolls. Specifying `left` allows the element to maintain its position relative to the left edge of its containing block when it reaches the specified scroll threshold.

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 encompasses all other elements within the document, including the `

` and `` sections. This tag signals to the web browser that the content enclosed is structured as an HTML document, allowing it to render the page correctly. By using the `` tag, developers establish a clear hierarchy and organization for the content, ensuring compatibility across different web browsers.
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 an element to flow with the document until a specified scroll threshold is reached. Once that threshold is crossed, the element switches to fixed positioning, remaining in a fixed location within the viewport as the user continues to scroll. This dual behavior enables elements to remain part of the document flow until they need to "stick" to a position on the screen, enhancing layout control and user experience.

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, which is the visible area of the browser window. This means that the element remains in a fixed location on the screen, regardless of how much the user scrolls the page. Unlike other positioning methods, fixed positioning ensures that the element does not move with the content, providing a consistent reference point for users. This is particularly useful for navigation bars or alerts that need to stay visible at all times.

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 removed from the normal document flow and positioned relative to its closest ancestor that has a position property set to something other than `static`. The `static` value is the default positioning for elements, meaning they follow the normal flow of the document. Therefore, if all ancestor elements are set to `static`, the absolutely positioned element will be placed relative to the initial containing block, typically the viewport. This behavior is crucial for controlling layout and positioning in web design.

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 moved from its normal position without affecting the layout of surrounding elements. This means the element retains its original space in the document flow, while you can adjust its position using the top, right, bottom, or left properties. This is useful for creating layered designs or for positioning elements in relation to their original placement, enabling more control over the layout without disrupting the overall structure of the page.

Submit

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

Explanation

The default value of the CSS `position` property is `static`, which means that elements are positioned according to the normal flow of the document. This positioning does not allow for any offset adjustments using top, right, bottom, or left properties. Elements with a `static` position will not respond to z-index, and they will stack in the order they appear in the HTML. Understanding this default behavior is crucial for effective layout design in web development.

Submit

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

Explanation

The `

` tag is used in HTML to define a table row. It acts as a container for table cells, which can be created using `` for standard cells or `` for header cells. By grouping cells within a row, the `` tag helps structure the data in a table format, allowing for better organization and readability of the information displayed. Each `` tag corresponds to a horizontal line of data in the table, making it essential for proper table layout.
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 encapsulated by the `
  • ` tag, indicating a list item. The provided answer correctly demonstrates this structure by using `
      ` to create the list and `
    • ` to specify the single item, making it the appropriate choice for defining an unordered list with one item. The other options either use incorrect tags or represent different types of lists.
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 appears in the browser tab and is also displayed in search engine results, making it crucial for user navigation and SEO. It helps users identify and differentiate between multiple open tabs, enhancing their browsing experience. The content of the `<title>` tag is typically concise and relevant to the page's content.
Submit

25. How do you write a comment in HTML?

Explanation

In HTML, comments are written using the syntax ``. This format allows developers to include notes or explanations within the code without affecting the rendered output in the browser. The text within the comment tags is ignored by the browser, making it useful for documentation or temporarily disabling code during development. Other formats like `//` or `/* */` are used in languages like JavaScript or CSS, but they are not valid for HTML comments.

Submit

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

Explanation

The `` tag is specifically designed for embedding images in HTML documents. It allows developers to display images on webpages by referencing the image source through the `src` attribute. This tag is self-closing and does not require a closing tag, making it a straightforward way to include visuals. Other options listed, such as ``, ``, and ``, are not valid HTML tags for inserting images.

Submit

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

Explanation

In HTML, an element's syntax includes the tag name followed by its attributes within the opening tag. The correct syntax for an anchor element (``) includes the `href` attribute, which specifies the link's destination. The structure `link` correctly places the attribute within the opening tag and properly closes the element with ``. This format ensures that the browser understands that "link" is the clickable text that directs to "page.html" when clicked.

Submit

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

Explanation

The `

` tag contains the visible content of a webpage, including text, images, and other elements that users interact with. It is part of the HTML structure that displays information in a web browser, while the `` section contains metadata and links to scripts or stylesheets that are not directly displayed. Thus, the `` tag is essential for rendering the main content that users see and engage with on a website.
Submit

30. What must every HTML document begin with?

Explanation

Every HTML document must begin with ``, which declares the document type and version of HTML being used. This declaration helps browsers render the page correctly by informing them that the document is an HTML5 document. It ensures that the browser interprets the markup in standards mode, promoting consistent rendering across different web browsers. Without this declaration, browsers may switch to quirks mode, leading to unexpected behavior in the display of the webpage.

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...
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...
A position: sticky element is constrained to stay within the...
The CSS property used to control which positioned element visually...
If you set position: absolute on an element and none of its ancestors...
For position: sticky to actually stick, you must set at least one of...
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!