Victor Profile picture
May 6, 2021 11 tweets 4 min read Read on X
I bet you don't know how powerful the <img> tag is.

Let's find out 👇
Here is the most simple case of using it.

If the path is correct, the browser will display a picture of the mobile phone.

So far so good.
Now, we forgot to specify the alt tag for better accessibility.

There are two important rules:

1. You should always specify it

2. If the picture serves decorative purpose, you should put an empty alt, so that screen readers don't read it.
If we place an image the way we did, we have two problems:

1. The image will be rendered to its full width and height

2. There will be a layout shift since the browser doesn't know how much space to reserve for the image, until it loads it

So we should specify dimensions.
But what if we want to display different images for desktop and mobile?

This is the so-called "Art direction problem"

For mobile we can:

1. Serve more lightweight image
2. Show cropped version of image focusing on the main aspect

We can solve this in two ways. 👇
The first is using the "srcset" and "sizes" attributes.

srcset: one or more strings separated by commas, indicating possible image sources for the user agent to use.

sizes: One or more strings separated by commas, indicating a set of source sizes.
Another approach is using <picture> tag.

This approach looks much cleaner for me.
What's the difference between these two approaches?

They do the same work, but have a difference:

🔸<picture> dictates what image the browser should use

🔸srcset gives the browser a choice. So this is a recommendation for the browser.
If you have images placed below the fold they will be loaded even if the user hasn't scrolled down.

That will result in huge traffic data loading right away.

To prevent this, you can set the loading attribute to "lazy"
There is also a cool decoding attribute.

When the browser downloads an image it has to decode it first before showing it.

Sync decoding:

text -> image decoding -> image -> text

Async: the image decoding will be deferred and run asynchronously.
So, we started from simple <img src="phone.jpg">.

Look what we have now!

And we didn't work on image placeholders (that's another topic I'll cover later).

Of course, this is a sample snippet, you can have much more sources and different configurations.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Victor

Victor Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @vponamariov

May 1
How to design almost any UI element.

A curated list of 61 articles 👇
Buttons
---

1. Button Design – Get Site Visitors to Actually Click Your Buttons by @uxpin



2. Designing button states: Tutorial and best practices by @edwche / @LogRocket



3. The Definitive Guide to Buttons in UX: Part 1 by Lauren Waage

uxpin.com/studio/blog/bu…
blog.logrocket.com/ux-design/desi…
medium.com/@lwaage2019/th…
Text fields
---

1. Text fields from Material Design



2. Text Fields Design from Radek (this one is impressive!🤩)



3. UI Designer’s Guide to Creating Forms & Inputs from @molly_hellmuth

m2.material.io/components/tex…
thestory.is/en/journal/tex…
uiprep.com/blog/ui-design…
Read 22 tweets
May 24, 2023
Today I turned 34.

Here is an updated version of the most helpful tweet I've ever posted.

How to design almost any UI element?

A curated list of 34 articles 👇
Buttons.

1. How To Design Better Buttons by @101babich and @smashingmag

👉 smashingmagazine.com/2016/11/a-quic…

2. Desperately seeking squircles

👉 figma.com/blog/desperate…
Thanks @Southclaws and @figma

3. Designing A Better Back Button UX

👉 smashingmagazine.com/2022/08/back-b…

Thanks @vitalyf Squircled button
Text fields

4. Text fields & Forms design — UI components series

👉 uxdesign.cc/text-fields-fo…

from @uxdesigncc by Taras Bakusevych

5. Validate it. The right way.

👉 dev.to/vponamariov/va…

By me :) Input anatomy
Read 18 tweets
Nov 23, 2022
Five UI/UX tips to improve your landing pages 👇

#SketchDesignChallenge 🔥
1/5. Poor text contrast on images.

Make sure that

🔷 the text on images is easy to read
🔷 it doesn't cover any important objects behind it (e.g. faces or products)
🔷 text contrast is good everywhere, not only on images
2/5. Navigation.

Don't hide navigation under hamburger icons on desktop devices.

That will hinder users to find necessary pages.
Read 6 tweets
Oct 17, 2022
CSS Tip ☝️

I needed to make a pill component that should have had a 1px border.

But when on hover it should be doubled.

It wasn't that easy, and here is why.
If you simply make a 2px border on hover it will increase the height and width of the pill.

Since you don't know in advance what the width is, and probably the pill might be multiline, I don't think using fixed height/width is a good solution.
Instead, what I did is - I used shadows.

The first border is 1px shadow, and the second border (in the hover state) is 2px shadow.

And that's basically it.

A simple, yet nice trick.
Read 4 tweets
Oct 17, 2022
Some things designers should learn by themselves
by Michael McWatters (link at the end)

I SO MUCH liked this that I'm going to share some parts from the article 👇
🔸 32% of your time will be spent labeling buttons.

🔸 Blood will be shed over any question that begins, “Should designers…”.

🔸 All the research in the world is no match for your CEO’s opinion.
🔸 The design will fail on one platform, and that platform will be the one your boss uses.

🔸 The delta between what you designed and what gets shipped can be measured in light years.
Read 9 tweets
Sep 6, 2022
One UI/UX problem. Seven examples. One thread 🔥

Clickable area.

Do you make it right? Let's find out 👇
1/7. Sidebar menus.

Make sure that sidebar links have enough clickable space.
2/7. Vertical navigation.

A typical case is when the navigation links of a landing page don't have extra clickable space.
Read 8 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(