When should you use...

Image or background-image?

You can show an image on a web page by using the <img> HTML tag, or by adding the image as a background of another HTML element using the background-image  CSS rule. How to make that choice? Short answer: one is related to content, the other one to design.

Short answer: <img> is related to the content, background-image is related to the design.

You're often tempted to employ the background-image CSS property because of how easy it is to control the behavior of the image inside of its container: you can make it contain inside of, or cover the parent container, and precisely position it by setting the point of origin and top and left offset values. But the choice between using the HTML tag or the CSS background-image property shouldn't be made because of that.

The header image here is a decoration. It's not part of the message of the document, it's optional. It should use the background-image CSS property.

Here, the header image is an illustration of the message of the document. It is necessary for the content. It should be an image declared in the HTML file using the <img> tag.

A journey into photography

Embark in a new adventure. Discover a new kind of practice and
a new generation of gear. Empower yourself to create
images like you've never before.

Don't lose a minute

A come back with many faces

A roll of Ektar 210 film with a medium format yashica camera body

EKTAR 120 Film

You forgot about it but it never forgot about you. Remember? It's the size of the palm of your hand.

A top view through the viewfinder of a Yashica medium format body

Shoot from the hip

Old reflexes are back in a snap. Master shooting from the hip again, be discreet, be patient...

A photographer framing a shot through the rangefinder of a compact Yashica camera

Rangefinder!

No back screen. Stick your eye to the body. And this doesn't count against your screen time

Yashica, your
new old friend

Mechanic, warm, analogic with
a twist, revamped for the XXIst
Century, it's been here for ages,
only waiting for you...

Don't lose a minute
The Yashica G, front camera body with a Zeiss 50mm 1.2

A come back with many faces

EKTAR 120 Film

You forgot about it but it never forgot about you. Remember? It's the size of the palm of your hand.

Shoot from the hip

Old reflexes are back in a snap. Master shooting from the hip again, be discreet, be patient...

Rangefinder!

Live your photography. And this doesn't count against your screen time

The images above are illustrating each of the 3 points. They're part of the content, they're using the <img> tag, and the object-fit CSS property with the value contain in order to fill up their parent container.

Here, the images are merely illustrating the specs, they're more a part of the page design than real content. They're declared using the CSS property background-image, which allow them to be layered and to repeat like a pattern.

Major differences between the <img> HTML tag and the CSS background-image property

Use case for using an <img> HTML tag

Use case for using the CSS background-image property

That's not a lot of use cases for background-images. There used to have more, because of the options brought by the background-size CSS property, but the same control is now possible on images using the HTML <img> tag, with the object-fit CS property..

How to control the position of images?

Control the position of an image using the CSS background properties

All those properties are supported by Webflow's Designer UI, in the Style panel.

  • The CSS property background-image is used to call the file, using a URL

  • The CSS background-position is used to set the point of origin, e.g. center, and the exact position from the origin.

  • The CSS property background-repeat defines if the image repeats, and ho, e.g. no-repeat or repeat-x.

  • The CSS property background-size defines the behavior of the image, e.g. contain or cover.

  • The CSS property background-attachment defines if the image position is fixed or not.

Control the position of an image using the HTML <img> tag

  • The CSS property object-fit is used to define the behavior of the image inside of its container. e.g. contain or cover.

  • The CSS property background-position  is used to set the point of origin, e.g. center, and the exact position from the origin.

  • An image using <img> tag can't repeat, and can't be fixed depending on the body, the way background-images can.

The background-position property is not yet supported. By default, img-positionvalue, when not declared, is 50% 50%, which means your image is zoomed from its center. You can easily add custom CSS rule to address this. In the example below, the CSS rule tell the image to zoom from its upper left corner.