Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

HTML and CSS Basics Quiz

Total questions: 20

Worksheet time: 15mins

Name
Class
Date
1.

What is the purpose of the tag in an HTML document?

a)

To display content in the browser window

b)

To link CSS files and provide meta information

c)

To define the main content of the page

d)

To create comments in the HTML

2.

How do you set the background color of a webpage to light blue using CSS?

a)

body { color: lightblue; }

b)

body { background-color: lightblue; }

c)

body { border-color: lightblue; }

d)

body { font-color: lightblue; }

3.

What is the purpose of a

tag in HTML?

a)

To create a new page

b)

To represent a block of content

c)

To create a click element

4.

What is the purpose of setting the z-index to -1 in a CSS overlay?

a)

To make the overlay cover the entire parent element

b)

To place the overlay behind the actual content

c)

To stretch the pseudo-element to all sides

d)

To change the color of the overlay

5.

What is the purpose of using the

tag in HTML as described in the document? <section>

a)

To style the text

b)

To embed a video

c)

To create a generic container for content

d)

To add a background image

6.

What is the function of the class "andy" in the HTML structure provided? <div class="andy">

a)

It embeds a YouTube video

b)

It is the main wrapper for styling

c)

It sets the video to responsive size

d)

It limits the iframe width

7.

What is the purpose of using "display: flex" in the .andy class?

a)

To create a parallax effect

b)

To center the iframe using Flexbox

c)

To add space inside the .andy box

d)

To set a scenic image as background

8.

What is the effect of setting "z-index: -1" in the .andy:before class?

a)

It makes the overlay opaque

b)

It positions the overlay above the content

c)

It sets the overlay behind the actual content

d)

It changes the overlay color

9.

Which CSS property is used to arrange child elements in a row?

a)

justify-content: space-between;

b)

display: flex;

c)

align-items: center;

d)

z-index: 999999;

10.

What is the purpose of using the aspect-ratio property in CSS?

a)

To change the color of an element

b)

To keep image dimensions consistent

c)

To add content using CSS

d)

To control the stacking order

11.

What does the flexbox feature help with in CSS?

a)

Aligning items in a row or column

b)

Adding a red background to links

c)

Making text white

d)

Setting the logo size

12.

In CSS, what does the z-index property control?

a)

The color of text

b)

The stacking order of elements

c)

The size of the logo

d)

The aspect ratio of images

13.

Which CSS property is used to hide an element by default?

a)

position

b)

display

c)

color

d)

min-width

14.

What does the `DOMContentLoaded` event signify in JavaScript?

a)

The entire webpage, including images and styles, is fully loaded.

b)

The HTML page's structure is loaded and ready.

c)

The JavaScript code has finished executing.

d)

The CSS styles have been fully applied.

15.

What happens if the `menuIcon` or `menu` is not found in the HTML when using the JS: <script>

document.addEventListener('DOMContentLoaded', () => {

const images = document.querySelectorAll('.fade-p');

const revealOnScroll = () => {

const triggerBottom = window.innerHeight * 0.9; // 90% from top of screen

images.forEach(img => {

const imgTop = img.getBoundingClientRect().top;

if (imgTop < triggerBottom) {

img.classList.add('visible');

}

});

};

// Run on scroll

window.addEventListener('scroll', revealOnScroll);

// Run once on page load

revealOnScroll();

});

</script>

a)

The script stops executing.

b)

An error message is printed in the browser console.

c)

The page reloads automatically.

d)

A new menu is created.

16.

What does the `placeholder` attribute do in an HTML form?

a)

It submits the form data

b)

It provides a hint about what to enter in a field

c)

It changes the form's background color

d)

It validates the form input

17.

What is the function of the `class="submit"` in the input element:

<input type="submit" value="Submit" class="submit">

a)

It changes the text color

b)

It applies specific styles to the submit button

c)

It validates the form

d)

It adds a new section to the form

18.

What is the purpose of setting 'max-width: 800px' in a form?

a)

To make the form fill its parent

b)

To prevent the form from becoming too wide

c)

To center the form vertically

d)

To add space between form fields

19.

What is the purpose of setting the background color to navy in the CSS code?

a)

To make the text invisible

b)

To make the elected element to the color of navy

c)

To add space above the text

d)

To change the font style

20.

Where is the paragraph tag?