Images, Media & Forms Flashcards

1
Q

What is the purpose of using images in web development?

A

To enhance the visual appeal and user experience of a website.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the common image formats used in web development?

A
  • JPEG
  • PNG
  • GIF
  • SVG
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which image format is best for photographs?

A

JPEG

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which image format supports transparency?

A

PNG

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

True or False: GIF format supports animation.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Fill in the blank: The _______ attribute is used to specify an alternative text for an image.

A

alt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the role of the <img></img> tag in HTML?

A

To embed images in a webpage.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What attribute can be used to set the width of an image in HTML?

A

width

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What attribute can be used to set the height of an image in HTML?

A

height

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does the ‘src’ attribute in the <img></img> tag specify?

A

The URL of the image.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the benefit of using CSS for styling images?

A

To separate content from design and allow for easier maintenance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Fill in the blank: The _______ property in CSS can be used to control the display of images.

A

display

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the function of the <figure> and <figcaption> elements in HTML?</figure>

A

To group images with their captions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

True or False: The <video> tag can be used to embed video content in a webpage.</video>

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What attributes are commonly used with the <video> tag?</video>

A
  • controls
  • autoplay
  • loop
  • muted
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the purpose of the <audio> tag in HTML?</audio>

A

To embed audio files in a webpage.

17
Q

What attributes can be used with the <audio> tag?</audio>

A
  • controls
  • autoplay
  • loop
  • muted
18
Q

Fill in the blank: The _______ tag is used to create forms in HTML.

19
Q

What are the common input types in HTML forms?

A
  • text
  • password
  • checkbox
  • radio
  • submit
20
Q

What is the purpose of the ‘action’ attribute in a form?

A

To specify where to send the form data when submitted.

21
Q

What does the ‘method’ attribute in a form define?

A

The HTTP method to use when submitting the form.

22
Q

True or False: The ‘GET’ method appends form data to the URL.

23
Q

True or False: The ‘POST’ method sends form data in the body of the request.

24
Q

You have an <img> inside a container that has max-width: 800px. The image is larger than this container. What CSS rules should you apply to ensure the image never overflows while maintaining its aspect ratio?

A
img {
  max-width: 100%;
  height: auto;
}

This ensures the image scales down if needed but keeps its original proportions.

25
Q

You want a background image to always cover an entire <div> but prevent distortion. Which CSS property ensures this behavior?

A

background-size: cover;

This makes the image cover the whole element while maintaining its aspect ratio, though some parts may be cropped.

26
Q

You’re embedding a <video> inside a responsive design. What CSS rules ensure the video scales properly without overflowing?

A
video {
  max-width: 100%;
  height: auto;
  display: block;
}

This makes the video adapt to the container while keeping its proportions.

27
Q

What’s the best way to associate a <label> with an <input> field for accessibility and why?

A
<label for="email">Email:</label>
<input type="email" id="email" name="email">

Using the for attribute links the label to the input, making it clickable and improving accessibility for screen readers.

27
Q

How can you change the color of placeholder text inside an <input> field?

A
input::placeholder {
  color: gray;
  font-style: italic;
}

This targets the placeholder text specifically.

28
Q

How do you make an <iframe> scale proportionally while maintaining a 16:9 aspect ratio?

A
.iframe-container {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 aspect ratio */
}

.iframe-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

This method ensures the <iframe> resizes dynamically while keeping its aspect ratio.

29
Q

You want an image to load different versions based on screen size. How would you use the srcset attribute to display:

small.jpg for screens below 600px,

medium.jpg for screens between 600px and 1200px,

large.jpg for screens above 1200px?

A
<img src="large.jpg" 
     srcset="small.jpg 600w, medium.jpg 1200w, large.jpg 1800w"
     sizes="(max-width: 600px) 100vw, 
            (max-width: 1200px) 50vw, 
            33vw"
     alt="Responsive Image">

This allows the browser to choose the best image size based on the device width.

30
Q

You have a form where inputs take full width on small screens but only 50% width on larger screens. How do you achieve this using CSS media queries?

A
input {
  width: 100%; /* Default: full width */
}

@media (min-width: 768px) {
  input {
    width: 50%; /* On larger screens, inputs take half width */
  }
}

This ensures the form adapts to different screen sizes.

31
Q

How do you hide the default checkbox but still allow it to be checked using a custom-designed label?

A
<input type="checkbox" id="custom-checkbox" hidden>
<label for="custom-checkbox" class="custom-box"></label>

<style>
  .custom-box {
    width: 20px;
    height: 20px;
    display: inline-block;
    border: 2px solid black;
    cursor: pointer;
  }

  input:checked + .custom-box {
    background: black;
  }
</style>

The checkbox is hidden, and a styled <label> is used as a custom checkbox.</label>

32
Q

How can you hide the default controls of a <video> tag and create your own play/pause button using JavaScript?

A
<video id="myVideo" width="400">
  <source src="video.mp4" type="video/mp4">
</video>
<button id="playPause">Play</button>

<script>
  const video = document.getElementById("myVideo");
  const button = document.getElementById("playPause");

  button.addEventListener("click", function() {
    if (video.paused) {
      video.play();
      button.textContent = "Pause";
    } else {
      video.pause();
      button.textContent = "Play";
    }
  });
</script>

This hides the default controls and adds a custom play/pause button.