How to Add a Background Image — HTML Technical Interview Questions & Answers

CSS background-image on the body or a section.

How to Add a Background Image

  • How to Add a Background Image (html) is a HTML topic. In plain words you use it for a student photo in the profile card. Don’t start with a slogan — start with that picture.
  • Smallest example: <img src="photo.jpg" alt="Asha">. Type it, run it, and say what you see. If you can do that from memory, you know How to Add a Background Image (html).
  • From the example next to this theory: CSS background-image on the body or a section.
  • Trap: empty alt on a meaningful image. Fix that before you talk about advanced HTML.
  • Viva: what is How to Add a Background Image (html)? Then show <img src="photo.jpg" alt="Asha">. Then name the trap.

Technical Interview Tip: What is How to Add a Background Image (html)? Show this: <img src="photo.jpg" alt="Asha">. Trap: empty alt on a meaningful image.

Code Examples for How to Add a Background Image

How to Add a Background Image — working example

<figure>
  <picture>
    <source media="(max-width: 640px)" srcset="/photos/team-sm.jpg" />
    <img
      src="/photos/team.jpg"
      alt="Students practicing interview questions at a workshop"
      width="480"
      height="320"
      loading="lazy"
    />
  </picture>
  <figcaption>Weekend mock-interview workshop</figcaption>
</figure>

<link rel="icon" href="/favicon.ico" sizes="any" />

How to Add a Background Image — alt describes the image; picture/srcset adapt assets; figure/figcaption caption media.

How to Explain How to Add a Background Image to an Interviewer

What is How to Add a Background Image (html)?

Used for a student photo the profile card Not just the heading

Give one small example of How to Add a Background Image (html).

<img src="photo.jpg" alt="Asha"> CSS background-image on the body or a section

What mistake do beginners make with How to Add a Background Image (html)?

empty alt on a meaningful image Show the fix

Where do you use How to Add a Background Image (html)?

the profile card a student photo