Forum Moderators: not2easy

Message Too Old, No Replies

If statements in HTML

use if statements in HTML depending on mobile/desktop browser

         

AndrewHill

12:46 am on Jan 1, 2018 (gmt 0)

5+ Year Member



Is there a way to use an if statement in html?

I am looking at mobile responsiveness on a site and one image isn't looking so great on mobile. I don't want to alter the CSS, I'm new to it and I expect this issue isn't going to be ongoing and if I do face this issue in the future, it'd be great to know what to do.

So, just to keep it simple. "Image A.png" is for desktop, "Image B.png" is for mobile.

How would I show it in html if I wanted one to show to desktop visitors and the other to mobile visitors?

topr8

2:00 am on Jan 1, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



you can look at the <picture> element

[developer.mozilla.org...]

where you can serve different images to different device widths.