Using CSS vs image

Is there any advatage to doing something like this with CSS compared to using an image?
No description
9 Replies
Kingpin
Kingpin5d ago
I think with rendering an image there is less computing time, with rendering using css it's easier to customize.
13eck
13eck5d ago
Define "advantage". With an image it's easier to use in multiple pages and super easy to change if/when change is needed. Though with CSS it's one less HTTP call since you're not downloading another file. As with everything, It Depends™
Kingpin
Kingpin5d ago
Right, didn't even consider the downloading part. Tho I don't think that specific gradient can be done with a one liner, if it can that it's gonna a kinda long one.
سمية
سميةOP5d ago
The one who posted it said we need multiple blended layers and SVG overlays. But I have no idea.
Alectric
Alectric5d ago
CSS could adapt to different dimensions dynamically. Images could only be scaled, and to avoid blurring, you'd need the image at the largest possible size. You can get around some of these issues with images by using the srcset attribute or a picture element, but that's extra work. An image can have a visible delay before it loads, possibly fail to load, and a user might even disable images for their browser.
StefanH
StefanH5d ago
keep it stupid simple -> use an image. if you run into issues, build it custom
capt_uhu
capt_uhu4d ago
agreed I don't know if it's really worth the effort to recreate this in CSS. Looks like something that could be an easy less an 10k image with the right image format. Lossy would probably work fine so jpeg, webp(lossy), avif
StefanH
StefanH4d ago
could store it grayscale and then tint it in style lol
Rägnar O'ock
Rägnar O'ock4d ago
What about an inline SVG?

Did you find this page helpful?