Victor Profile picture
27 Apr, 16 tweets, 6 min read
15 Common CSS mistakes developers make πŸ‘€

πŸ‘‡
1. Not using a CSS reset

Each browser has its own default styling for HTML elements.

I'd say it's not just good practice, it's a MUST to reset the styling to some default values and then start styling from scratch

That will help:
necolas.github.io/normalize.css/
2. Starting with the desktop version

It’s easier to develop for a small screen before scaling the design up to a large screen.

You can always make existing elements bigger to fill a blank space on a larger screen.

But it's harder to do it vice versa.
3. Deeply nested selectors

Just because the DOM tree looks one way does not mean the CSS should match it.

HTML is for structure. CSS is for styling.
4. Using px units

I found a nice answer from Stack Overflow: stackoverflow.com/a/43131958/106…

Pay attention that the answer from 2012 stated that you should use px.

But the second answer explains that it's fine to use relative units nowadays.
5. Writing 0px

This is just redundant: instead of 0px you can just use 0.

❌ Bad:
margin: 10px 0px 15px 0px;

βœ… Good:
margin: 10px 0 15px 0;
6. Using color names instead of hex code

While it seems that there are 17 standard colors (w3.org/TR/CSS21/synda…), I think it's a very bad practice to use color names.

Who knows how they'll be rendered.

Plus you still need a lot of custom colors, so why not be consistent?
7. Putting block elements in inline

From Mozilla docs:

Generally, inline elements may contain only data and other inline elements.

You shouldn't put block elements inside inline elements. πŸ‘†
8. Missing alt text for images

Alt is a required (!) attribute for images (w3schools.com/tags/att_img_a…)

Screen readers use alt to understand what the image is about.

If the image serves DECORATIVE purposes, then you should put alt="" (an empty string)
9. Repeating the same code

It often happens that in big projects you keep on writing the same styling, because it's easier to add one class, than refactoring the whole project.

But it's not a good thing and you should avoid it.

Frameworks like @tailwindcss might help
10. Duplicating font-family everywhere

Another thing related to code duplication is FONT duplication.

I often see that developers copy-paste styles from Sketch/Figma, and end up having the same font-family and line-height.
11. Z-index hell

If you worked on a large project, then you probably tried desperately something like: z-index: 99999.

Managing z-indexes is not that easy.

Check out this article from @smashingmag
smashingmagazine.com/2021/02/css-z-…
12. Not knowing the difference between visibility and display

`visibility: hidden` = It is not visible but gets up its original space

`display: none` = It is hidden and takes no space.

This is important to know πŸ‘†
13. Not using shorthand syntax, when it's reasonable

Sometimes it's not reasonable to use shorthand syntax, e.g. for the font property.

However, when it comes to margins/paddings/borders etc, it's perfectly fine.
14. Not using semantic tags

HTML has a lot of semantic elements, like <article>, <header>, <footer>.

Use them instead of <div>, it will help for SEO & screen readers.
15. Not providing fallback fonts

It might happen that the user doesn't have installed the font you use.

In this case, you can specify other fonts and font families (!) that should be used.

β€’ β€’ β€’

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

23 Apr
How user interface evolved for the past 40 years ✨

Visual Thread 🧡
Xerox 8010 Star, released in 1981

It was the first commercial personal computer that had
such things as

- window-based graphical user interface
- icons
- folders
- mouse (two-button)
- Ethernet networking
- file servers
- print servers
- e-mail.
Apple Lisa Office System 1. Released on January 19, 1983.

It is one of the first personal computers to present a graphical user interface (GUI) in a machine aimed at individual business users.
Read 17 tweets
22 Apr
What to do if

- you start a side project
- you are a developer
- you don't have a designer? πŸ€”

🧡 Practical guide
1/9

First of all.

Check your competitors. I had 170+ competitors in the market.

There are for sure plenty of similar products, at least with similar features.

Make a list of them. Take screenshots of their pages. And put all this in a single place (Figma/Sketch)
2/9

Now, let's be honest. You don't have money for paying UX research for building

- wireframes
- informational architecture
- personas
- doing research
- making customer journey maps etc

Admit it. You're a side hustler and you probably don't want to spend years and $$$.
Read 10 tweets
21 Apr
How to make this hover effect with CSS only πŸ‘‡
First, you need an SVG with such a curved line.

You can create one in any vector editor.

So here is an example of HTML you can have.
Next, the CSS part

1. The SVG should be positioned absolutely, below the link

2. The path should have `stroke-dasharray` and `stroke-dashoffeset` properties.

3. Apart from that it should have transition settings so that the animation would be smooth
Read 5 tweets
21 Apr
If you're a solo founder or developer, you might actually don't need a designer.

Here is why 🧡
1/7

There is the Pareto principle that says that you can achieve 80% of the result, making 20% effort.

You might not have a perfect design, but it'll be 80% good if you follow some basic principles of design.
2/7

These design principles are not hard to learn.

Most of them are UX gestalt principles, UI patterns, common sense.

It'd be enough to read a @refactoringui book, for example, that will level up your skills dramatically
Read 8 tweets
20 Apr
10 really DARK & TRICKY UX patterns you should never use 😈

πŸ‘‡
1. Forced Continuity

There is a popular joke: "Why do you need my credit card if it's a free trial?"

The trick is that when your trial ends, you start getting charged.

Usually without reminders, and without an easy way to cancel the subscription.
2. Price Comparison Prevention

The retailer makes it hard for the user to compare the price of an item with another item, so they cannot make an informed decision.

For example, it's hard to compare weight (kg) and the package of pears (without knowing the package weight)
Read 11 tweets
19 Apr
20 UX Laws & How to apply them (illustrated) πŸ‘‡
The rule of the first impression

It takes a fraction of a second to make a good/bad first impression.

Things that users see when they start interacting with your product will shape their opinion.

That's why I'm starting this thread with this rule & attaching a nice video
Picture Superiority Effect

Pictures and images are more likely to be remembered than words.

Use visual storytelling in your products.

By pairing text with images, you increase the chance that users will remember the information.
Read 21 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

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

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!