惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threatpost
博客园 - 叶小钗
T
The Blog of Author Tim Ferriss
Recent Announcements
Recent Announcements
D
DataBreaches.Net
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
罗磊的独立博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
N
Netflix TechBlog - Medium
Microsoft Azure Blog
Microsoft Azure Blog
Microsoft Security Blog
Microsoft Security Blog
B
Blog
U
Unit 42
有赞技术团队
有赞技术团队
博客园 - 聂微东
GbyAI
GbyAI
宝玉的分享
宝玉的分享
F
Full Disclosure
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
MyScale Blog
MyScale Blog
Jina AI
Jina AI
Martin Fowler
Martin Fowler
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
D
Docker
P
Proofpoint News Feed
A
About on SuperTechFans
I
InfoQ
博客园 - 【当耐特】
C
Check Point Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy & Cybersecurity Law Blog
T
Threat Research - Cisco Blogs
Y
Y Combinator Blog
Project Zero
Project Zero
WordPress大学
WordPress大学
小众软件
小众软件
AWS News Blog
AWS News Blog
博客园 - 司徒正美
T
The Exploit Database - CXSecurity.com
L
LINUX DO - 热门话题
I
Intezer
Engineering at Meta
Engineering at Meta
C
CXSECURITY Database RSS Feed - CXSecurity.com
J
Java Code Geeks
T
Tenable Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Last Week in AI
Last Week in AI
C
CERT Recently Published Vulnerability Notes

Ahmad Shadeed

Better fluid sizing with round() Use Cases for Field Sizing The Basics of Anchor Positioning Item Flow CSS Relative Colors Balancing Text In CSS Should masonry be part of CSS grid? CSS display contents CSS Grid Areas CSS Cap Unit An Interactive Guide to CSS Container Queries CSS :has() Interactive Guide CSS Nesting UX in DevTools CSS Nesting Future CSS: State Container Queries Rebuilding a comment component with modern CSS Conditional CSS with :has and :nth-last-child CSS Text balancing with text-wrap:balance CSS Masking Do we need CSS flex-wrap detection? My CSS Wishlist Conditional CSS CSS Style Queries Inside the mind of a frontend developer: Article layout Inside the mind of a frontend developer: Hero section CSS container queries are finally here The CSS behind Figma First Look At The CSS object-view-box Property Learn CSS Subgrid CSS :has Parent Selector Aligning Content In Different Wrappers Flexbox Dynamic Line Separator Hello, CSS Cascade Layers Building UI Components With SVG and CSS A Deep CSS Dive Into Radial And Conic Gradients Defensive CSS Building Real-life Components: Facebook Messenger Conditional Border Radius In CSS CSS Container Query Units Aligning a Button Label Vertically Comparing Design Mockups To Code Result Using HSL Colors In CSS Custom Scrollbars In CSS Let CSS Container Queries For Designers The State of CSS Cross-Browser Development Overflow Issues In CSS Inspect Element As A Way To Increase Your Curiosity Handling Text Over Images in CSS Digging Into CSS Logical Properties Clipping Scrollable Areas On The inline-start Side Understanding Clip Path in CSS The Art of Building Real-life Components Handling Short And Long Content In CSS CSS Scroll Snap A Deep Dive Into CSS Grid minmax() CSS Variables 101 Finding The Root Cause of a CSS Bug Learn CSS centering How to detect browser support for Flexbox Gap CSS Mistakes While On Autopilot Digging Into the Flex Property Understanding CSS Multiple Backgrounds Aligning Logo Images in CSS Grid for layout, Flexbox for components Colors in CSS Thinking About The In-between Design Cases min(), max(), and clamp() CSS Functions Image Techniques On The Web Everything About Auto in CSS Learn Box Alignment Let Learn CSS Positioning Intrinsic Sizing In CSS CSS Grid Template Areas In Action Hiding Elements On The Web Creating a Variable Color Font From Scratch Building a Football Ticket With CSS and SVG Blending Modes in CSS CSS Variables With Inline Styles Implementing Dark Mode For My Website Rebuilding Apple Music Header in HTML & CSS Accessible Checkbox Layout Flickering On Browser Resize Enhancing The Clickable Area Size Custom Underlines with SVG Part 3: The Process of Implementing A UI Design From Scratch Part 2: The Process of Implementing A UI Design From Scratch Building An Old Nav Design CSS Flexbox: 5 Real World Use Cases I Used CSS Inline Flex For The First Time The Process of Implementing A UI Design From Scratch Common CSS Issues For Front-End Projects Handling Long and Unexpected Content in CSS How to Build Web Form Layouts With CSS Grid Grid Layout Ah-ha Moment Enhancing Our Components with CSS :empty Building Resizeable Components with Relative CSS Units CSS Writing Mode The Journey of Learning Front End Web Development on a Daily Basis
Tweaking In The Browser
Ahmad Shadeed · 2022-04-03 · via Ahmad Shadeed

The Layout Maestro

I spent years teaching CSS layout on this blog. I put everything I know into The Layout Maestro course: 70+ lessons and 150+ interactive examples that teach you how to think CSS layouts, not just memorize syntax.

Get the course

A while ago, I got to think about the term “Designing in the browser” and if it’s a valid thing at all. The term “designing” in the browser indicates that we can add design elements quickly, but if we compare that to a design tool, like Figma, then the tool will win in terms of speed.

When we have an already implemented design in the browser, then it’s so much easier to tweak it, and eventually, we might “design” something different from what we started with. I like the term “tweaking” better for that context. The question is, what do we need to be able to design in the browser? And what we can do in the browsers with the current developer tools?

Introduction

The term “designing in the browser” is so vague to the point that some designers and developers think that web browsers are design tools. This thinking implies that if we have an HTML markup, then we can start designing in the browser, just like a design tool (e.g: Figma). No, that’s not the point!

Let’s take the following example for a recipes website. We have the following sections:

  • header
  • search
  • featured recipes
  • recipes listing
  • and so on.

Can we design the following in the browser at the same time we do it in a design tool?

For me, the short answer is no. There are many reasons why designing such a website in the browser can’t be practical. It’s not hard nor impossible, but it’s impractical!

Let’s get into a few of these reasons.

Why designing in the browser doesn’t work for me

It takes time

While designing, we want to explore ideas in the shortest amount of time. Writing HTML/CSS code and thinking about the design at the same moment will double or triple that time.

Let’s take the header as an example. To think and design this in the browser, we need to take care of the layout, spacing, alignment, exporting icons, font sizes.. and a lot more.

It takes time in that case because we first write the CSS needed, and then check it in the browser to see if all is as intended. Maybe that icon isn’t sized properly, or a specific selector isn’t working because we forgot to append the dot before the class name. Lots of tiny scenarios!

Here is a very simple case where creating a simple rectangle for the header, is way faster than doing this in code (AKA: designing in the browser).

It’s not even the same result! In the browser, I still need to add the rest of the elements, then add padding for the navigation elements to make the header height reasonable.

While in Figma, it’s just a two steps process:

  1. Create a rectangle
  2. Pick a background color

Another example is the search form. I tried to code it in the browser and compare the actual time. It took me about it 8 minutes while in Figma it only took 1-2 minutes. To make it look like the intended design, we need to:

  • Reset the default design by adding appearance: none.
  • Removing the border, border-radius.
  • Added the placeholder color (Fun fact: I looked it up in CSS tricks because I don’t memorize the vendor prefixes).
  • Added the search icon via a CSS background, then handled the sizing, positioning..etc

Here is the basic HTML and CSS code.

And this doesn’t even account for different screen sizes, and I didn’t also show the flex parent for it. While in Figma, it’s only a rectangle with an icon and a bit of border-radius.

This should be called designing in the browser. When designing, we need to clear our minds from all those CSS properties and focus on the design itself. The only situation I would design in the browser is when I have all the time in the world and there is a project without a deadline.

You might face a CSS issue

Chances are high that you might be stuck with a CSS layout problem that will increase the time to design even more. For example, I sometimes write CSS properties with tiny typos and I only notice them If I look in the DevTools and see which CSS property is invalid.

.search-input {
  disply: flex;
}

The property disply is a typo and it won’t be visible unless you check the result in the browser. You will first notice that the flex parent isn’t even there. Why bother wasting such time while your mind is “designing”? It doesn’t make sense.

A constant context switching

You need to think about the look & feel of a design, and also how to write the CSS for it. This context switching isn’t good (at least for me). I just can’t focus that way.

Here is how my mind looks when I think about the look & feel and writing CSS at the same time.

Let’s suppose that I want to design the following section.

For this kind of layout, I might not be able to decide if the card design is good enough unless I duplicate the card to fill the grid I have.

Here is what I might be thinking about while switching context between design and CSS:

  • Do you I need to wrap this within a link to make it clickable?
  • Oh oh, I wrapped it in a link. Now I need to treat the <a> element as a flex wrapper.
  • The card title is shifted from the bottom and left sides. What should I use: margin or position?

Do you see what I mean? Why answer or even think about such a question while the current goal is to only explore the design in the fastest time possible?

It’s harder to duplicate a design in the browser

While working in a design tool like Figma, it’s easy and quick to duplicate a canvas and explore another design option. In the browser, we will mostly duplicate the .css file and explore something else, or maybe add a new class and take it from there.

I’m not asking for a web browser to allow us to duplicate pages or anything else, since it doesn’t make sense to me. I prefer to have this feature in design tools only.

DevTools takes from the screen estate

Not everyone has a 27” display, so opening the browser DevTools will take so much from the screen estate, and this will affect the workflow of “designing” in the browser.

One solution is to pop out the DevTools into a separate window, but this isn’t a practical solution. You will keep circling between two different windows (The browser tab and the DevTools).

Now that I explored the reasons why designing in the browser doesn’t work for me, let’s get into why I prefer to call it “tweaking” instead.

For me, I see the term “tweaking” much clearer than “designing”. Simply because it doesn’t give false hopes to newcomers, or designers who might think that web browsers are actually design tools.

What I like about tweaking in the browser is the document flow. You change something, its size gets bigger, and it will push its sibling elements down.

While in a design tool, this won’t happen unless you’re using Auto Layout, which can’t be used for everything. Sometimes you simply want to try and experiment quickly with a design.

Consider the following figure. On the left, we have a list of different elements. When one of them gets bigger, the rest will be pushed down.

In a design tool, an overlap will happen (Notice how the pink element overlaps with the one under it).

In the following points, I will explore a few cases where I’m a big fan of tweaking in the browser.

Tweaking color scheme

When using CSS variables for everything, we can easily tweak the color values and test different colors until the result is satisfying for us. In a design tool, this is possible, but it’s way less flexible compared to a browser.

Do you see the point? Some things are better to be done in a browser rather than a design tool.

:root {
  --primary: #d66636;
  --secondary: #222;
  --gray-0: #fcf5f2;
}

Tweaking font size

In design tools, if we’re not using a technique like Auto Layout in Figma, text elements will collapse when we change their size. See the following figure:

However, When all the fonts are built based on CSS variables, we can simply change a few variables, and the font size will be reflected on all text elements.

:root {
  --text-1: 1rem;
  --text-2: 1.25rem;
}

p {
  font-size: clamp(1rem, 5vw, var(--text-2));
}

Tweaking font family

Similar to the font size, we might need to test out a few different fonts for a UI. In design tools, this is a nightmare for me, even if I use shared styles and Auto Layout in Figma, it is still an annoying process to do.

Grid layout/system

Altering the grid layout in a browser is much faster now, given CSS grid has very good browser support! For example, we can use grid-template-areas to name areas in a grid and then alter the child elements based on it.

Consider the following example.

.c-newspaper {
  display: grid;
  grid-template-columns: 0.2fr 0.6fr 0.2fr;
  grid-template-areas:
    "item-1 featured item-2"
    "item-3 featured item-4"
    "item-5 item-6 item-7";
  grid-gap: 1rem;
}

.c-article--1 {
  grid-area: item-1;
}

.c-article--2 {
  grid-area: item-2;
}

Do you want to try a different placement for a specific component? Easy, just change the grid-area to the area you want. If you’re not familiar with CSS grid areas, I wrote a detailed article on the topic.

Responsive typography

How would you implement a responsive type in a design tool like Figma? It’s not possible. By responsive, I mean being able to see how a specific text element is changing based on specific constraints, not for two or three different sizes only.

Here is how I see the current state of design tools vs browsers, in regards to typography.

Thanks to CSS comparison functions, we can now do that in CSS by using the clamp() function.

.title {
  font-size: clamp(1rem, (1rem + 5vw), 3.125rem);
}

Container queries

CSS container queries are being worked on now by Chrome, Edge, and Safari TP. It’s a CSS technique that will allow us to query component based on their container or parent.

For designers, that might change the way how we think and design. For example, instead of providing the developer with 4 different sizes of the home page, we can provide only the component that will have major changes based on the container size.

Consider the following example where we have 4 different versions of a card component.

We can also make a diagram of the context of each version. This will help to communicate the design with the development team.

I wrote a deep-dive article on how container queries will be beneficial for designers.

Multilingual design

Given that I’m a designer myself, I’ve been asked many times by clients and project managers to deliver two versions of a UI, one for each language. For me, this is a nightmare to work on.

I simply reject that and tell them that I will only provide only the main screens along with the typeface to use and such details.

By using CSS techniques like flexbox, grid, and logical properties, we can switch a design from LTR (left-to-right) to RTL (right-to-left) by only changing the dir attribute on the root element (e.g: <html dir="rtl">).

Consider the following example.

If we’re using flexbox, grid, and logical properties for everything, things will be very straightforward when we want to switch the design direction.

For example, for the search input, we can write the padding as the following:

.input--search {
  padding-inline-start: 2.5rem;
  padding-inline-end: 1rem;
}

That being said, tweaking a design to make it RTL in the browser is so much easier than doing it in a design tool. If you want to learn more about RTL styling in CSS, here is a guide by yours truly.

Final words

I tried to explore and share my perspective on how I use both design tools and browsers to achieve what I need. Sometimes, a design tool is better, and sometimes it’s the browser. The term “tweaking” is so much better, at least for me.

On the other hand, I don’t expect that browsers should have features for designing in the DevTools since this isn’t the browser’s job in my opinion. We have too many features in DevTools already. Design tools are meant to give us the flexibility to try and explore ideas, while web browsers are made to help us achieve the best user experience possible given the constraints and limitations we might have.