Code made me a fussier designer
I asked for a box 300 pixels wide and the browser gave me one 342 pixels wide. I checked my typing. I checked it again. Then I did what any calm professional would do and glared at the screen.
I learned to code at Enspiral Dev Academy, where I did a web development bootcamp and my group built the Odd Jobs Web Portal. I thought I understood layout. The browser had other ideas.
The 42 extra pixels turned out to be mine. I’d given the box 20 pixels of padding on each side, which is the breathing room between the edge and the words inside, plus a 1-pixel border. Left to itself, CSS counts the width as the words only and then adds the padding and border on top. 300 plus 40 plus 2.
There’s a one-line fix, box-sizing: border-box, that makes 300 mean 300. Most developers put it in at the start and never think about it again. I think about it a lot, because of what it showed me about my own habits.
What I used to do
In Illustrator or Sketch, a thing sits where I put it. If a gap looks wrong I nudge it. Then I nudge it back. The gap ends up at whatever number my eye was happy with at 11 pm.
I went back through an old mock-up afterwards and measured the gaps. 17, 19, 22, 23, and one lonely 31. Each one placed by hand, with love, and with no system whatsoever.
A browser can’t build “about 19, but 22 on this one screen”. Somebody has to type a number, and if I haven’t chosen it, they will.
What I do now
I pick a short list of sizes before I start: 8, 16, 24, 32 and 48 pixels. Every gap on the page has to be one of them. Between a label and its field, 8. Between two paragraphs, 16. Between sections, 48.
I expected to feel boxed in, and it’s been the opposite. I don’t agonise over 19 versus 22 any more, because neither is on the list. The page looks calmer too, in a way that’s hard to point at. Things that belong together sit close, things that don’t sit apart, and it’s the same close and the same apart all the way down.
It changed how I talk to developers as well. I used to send a screenshot with an arrow and “feels a bit tight?” written on it. Now I can open the browser’s inspector, the panel that shows the numbers behind a page, and say the margin is 16 where it should be 24. That’s a one-minute fix, and nobody has to guess what “tight” means.
I’m not a developer, and I don’t think every designer has to become one. Building one small page by hand taught me most of it. A web page is a set of instructions for a rectangle I don’t control: somebody else’s screen, at somebody else’s text size. Writing the instructions myself, even badly, got me out of the habit of designing a screenshot.
Note to self: if a gap isn’t on the list, it’s a nudge. Put it back.
If I don’t choose the size of a gap, someone else has to type a number for me.