Accessibility Considerations
Before you get started, just keep in mind that images are a very visual medium. Visitors to your website might have any number of visual abilities. Blindness, Color-blind, Poor vision requiring large text, etc. When using images you should carefully consider their impact. Images that contain text that the visitor is meant to read should have that text transcribed into the alt
attribute.
All image elements should have alternate content for visitors. <img>
must contain the alt
attribute.
Background images are decorative. If you are using background images that are important content, then you should find a way to represent that.
Background Images
Background Image
Fixed Background Image
Background Image Cover
Background Image Contain
Background Image Non-repeating
Background Image: Positioned to Bottom Right
Background Image Resized
Gradients
Example gradients
Linear Gradient at 90° with set points
Linear Gradient with multiple colors
Radial Gradient with a transparent color
Radial Gradient with a transparent color and set points
Radial Gradient set to circle with a transparent color and set points
Conic Gradient with multiple colors
Image Styles
Responsive Image Styles
Images need a little help to properly be responsive.
img {
height: auto;
max-width: 100%;
}
This code makes it so that your images will shrink to fit the available space, but won’t expand larger than the image’s actual size, which would cause blurring issues.
Object fit works much like background-size
, with values like cover
and contain
.
CSS Filters →