| Post Reply | RetroFed Forum Forum Index » HTML |
| Author | Message | ||
|---|---|---|---|
codeinabox
programming.dev
codeinabox@programming.devJoined: 2025-09-29 |
|
||
| 14 Original | |||
Zachariah
lemmy.world
Zachariah@lemmy.worldJoined: 2023-06-13 |
tldr… Don’t use this:
and:
|
||
| 16 | |||
|
Hayduke
lemmy.world
Hayduke@lemmy.world Joined: 2023-09-05 |
We had an agency rebuild our website and discovered that they had both a mobile and desktop version of our entire product page in the dom that flipped via media queries. That was a huge issue for SEO and performance. I cant tell if they were just being lazy or didn’t know about grid templates. I’m guessing both, though I know most of it was vibe-coded. Fun stuff to clean up. At least they (over) leveraged picture elements |
||
| 8 | |||
|
refalo
programming.dev
refalo@programming.dev Joined: 2024-04-13 |
tldr… Don’t use this: <div class="image-wrapper"> <img class="image--desktop" src="/image-desktop.jpg" width="1200" height="400" alt="Super descriptive text"> <img class="image--mobile" src="/image-mobile.jpg" width="600" height="800" alt="Super descriptive text"> </div> and: .image--desktop { display: none; } @media (min-width: 1200px) { .image--mobile { display: none; ...
You can't style the sources differently, but you can with img tags. Also the picture element is less than ten years old. |
||
| 4 | |||
|
nebeker
programming.dev
nebeker@programming.dev Joined: 2023-12-28 |
tldr… Don’t use this: <div class="image-wrapper"> <img class="image--desktop" src="/image-desktop.jpg" width="1200" height="400" alt="Super descriptive text"> <img class="image--mobile" src="/image-mobile.jpg" width="600" height="800" alt="Super descriptive text"> </div> and: .image--desktop { display: none; } @media (min-width: 1200px) { .image--mobile { display: none; ...
Thanks for the TLDR! That looks very clean and handy. You accidentally replaced the |
||
| 3 | |||
codeinabox
programming.dev
codeinabox@programming.devJoined: 2025-09-29 |
You can't style the sources differently, but you can with img tags. Also the picture element is less than ten years old.
Could you achieve the same thing with media queries?
According to caniuse, since March 2016 it works across the latest devices and major browser versions. So it depends if you have users with very old browsers or devices. |
||
| 2 | |||
|
refalo
programming.dev
refalo@programming.dev Joined: 2024-04-13 |
You can't style the sources differently, but you can with img tags. Could you achieve the same thing with media queries? Also the picture element is less than ten years old. According to caniuse, since March 2016 it works across the latest devices and major browser versions. So it depends if you have users with very old browsers or devices.
Not always. Suppose you wanted different sets of colors (per source) on mobile vs desktop where the screen/media size was irrelevant, you'd need a way to attach classes to individual source elements, but they don't accept classes.
I was more mentioning that because of developers not always using the latest browser features. |
||
| 1 | |||
| Post Reply |
Back to top |