The case isn’t closed: padding-left vs margin-left

Previously on the CogitActive Saga:
If both AIs could so easily reverse themselves — not just after a casual “Are you sure?” but even after months of confident argumentation — what weight could I give to any of their claims? If the testimony can flip so quickly, what am I supposed to believe? And more importantly: how could I trust them?

Introduction

Apology to my readers,

Thank you for your patience as this “short interruption” grew into something much larger — and for staying with me through the twists and turns. What was meant to be brief — a single post to settle a small technicality — has turned into something far longer than I anticipated. Instead of a quick detour, you’ve been dragged with me into a full‑blown courtroom drama, complete with arguments, counter‑arguments, and testimony that flipped at the very end. But that was not the end!

After all that, there’s still no definitive resolution. In the end, all that courtroom drama brought me right back to square one. After pages of arguments, I was left with no verdict I could trust. The supposed experts contradicted themselves, the evidence felt shaky, and the judge — that’s me — had no choice but to declare a mistrial.

Without an answer, I can’t bring the larger series on the <section> element to its conclusion just yet. So here I am again, staring at the same stubborn question: padding‑left or margin‑left? This time, I’ll examine it without theatrics, without reversals, and without appeals, determined to reach a verdict that holds. Let’s hope this post will mark the end of that trial and close the chapter on the padding‑left vs. margin‑left case.

Motion for reconsideration

A mistrial doesn’t mean the case disappears. It only means the evidence has to be re‑examined with fresh eyes—my eyes this time. Since those earlier conversations, I’ve read more — a lot more, including about the CSS box model — and I’ll first revisit the transcripts, hoping to spot something useful I missed before. After all, I once let the margin‑collapse argument sway me, only to discover later that it applied vertically, not horizontally. That mistake won’t happen again.

Misunderstanding of intent

We discussed the topic extensively. I laid out my goals in detail: to indent the entire content of each section in order to make the heading hierarchy visible to sighted users, the same way semantic nesting benefits machines. I even warned Copilot against its frustrating habit of flipping positions mid-argument. And yet, despite my efforts, both AI often claimed I wanted something I never asked for.

I am not saying that maybe their initial preference for padding-left was based on what they (wrongly) thought I wanted, but instead that maybe their flip was somehow justified. If they misunderstood my intent and if I can pinpoint where that interpretation diverged, I might be able to view their reversal with a more generous eye. It may feel like a detour — perhaps even a waste of time — but double-checking the transcripts might be the only way not to discard the whole discussion.

Take Copilot’s early claim: “You’re not trying to move the section box relative to its parent — you’re trying to move the content inside relative to the section’s own edge.” That’s not quite right. I wasn’t trying to shift content for aesthetic reasons. I was trying to mark — without using background color — the boundaries of each section so sighted readers could see which paragraphs belonged to which heading. That’s a structural goal, not a stylistic one. But even after I clarified that point during the discussion, it made no difference — the recommendation for padding-left remained unchanged.

Before even reaching the flip, Copilot had already begun shaping its argument around a misread of my intent. “Your intent is ‘indent the content of this section,’ which semantically aligns with padding (internal spacing), not margin (external spacing).” That sounds convincing — until you realize it’s not what I said. My goal was to make the nested structure visible to sighted users, not to shift content for internal containment. More precisely, I wasn’t asking to indent the content within the section, but to shift the entire section itself — a subtle distinction, perhaps, but one that might just be enough to tip the balance.

Then came another confident assertion: “Margin doesn’t better communicate hierarchy; it only repositions the section’s box in its parent, which is not your intent.” Really? Because repositioning the section’s box — visually offsetting it from its parent — is precisely what creates the cue of nesting. That’s how lists, comments, and outlines work. If anything, that statement undermines the padding argument and inadvertently strengthens the case for margin. And yet, no flip followed. The recommendation stood firm, built on a foundation I had already corrected.

Later, after its flip, Copilot offered a new rationale: “The earlier ‘padding’ recommendation was based on the assumption that the indent was part of the section’s internal space, but your preference for the background not filling the gap flips that.” Again, not quite. My preference wasn’t about background behavior — I had already rejected background color as a solution. The background test was diagnostic, not prescriptive. It helped reveal how indentation behaved, but it wasn’t my desired outcome.

At one point, it claimed: “In your case, the nested <section> is the child, and padding-left on the parent <section> makes that relationship clear.” But I wasn’t styling the parent — I was applying indentation to the child section. That misunderstanding alone could invalidate its entire reasoning. Then came another assertion: “Your primary goal is not internal containment but visual hierarchy between elements.” No — my goal was to make the semantic nesting visible to sighted users, using indentation as a structural cue. That’s not about hierarchy between elements; it’s about showing which content belongs to which heading. And finally (after the flip), Gemini tried to seal its case with: “margin-left and background-color will give you the clean visual bands you described.” Except I never asked for visual bands. I asked for indentation — plain, uncolored, structural indentation. The background-color test was a tool, not a solution.

Each of these misinterpretations, while subtle, could have steered the recommendation toward padding-left — and later, justified the flip to margin-left. If their reasoning was built on a flawed understanding of my intent (despite my thorough explanations), then the entire case needs to be re-examined. Not dismissed, but re-evaluated — carefully, and this time, on my terms.

Reframing the evidence

If the original testimony was built on shaky assumptions, maybe the real clues lie within the very arguments used to defend them. After all, if the recommendations were shaped by a misread of my intent, then even their supporting logic deserves a second look. Many of Copilot’s arguments were presented as clear-cut — padding for internal spacing, margin for external offset. But when re-examined through the lens of my actual goal, those distinctions begin to blur. What was once framed as a limitation often turns out to be a strength. This section revisits those claims, not to dismiss them outright, but to reinterpret them in light of what I now understand about visual nesting.

Padding vs margin comparisons came early — and with them, the contradictions began to surface. “Margin: Indent is outside the section. You’re shifting the entire box.” That was meant as a drawback, but in my case, it might be the very behavior I need. “Margin also stacks horizontally, but because it’s external, every nested level also pushes the whole box rightward relative to siblings/parents.” Again, framed as a limitation — but isn’t that how visual nesting works? Lists 1, comments 2, and outlines all rely on this pattern. Even Copilot acknowledged: “Those patterns usually indent the whole block relative to its container, not just its content. That’s why margin-left is common there — the indent is an external offset, not internal padding.” That’s not a flaw. That’s precedent.

And then there’s the behavior of inner elements. “Margin: Those inner elements start at the section’s own content edge.” That’s precisely what I observed when testing sections without indentation — they behave like this by default. It’s not a bug. Yet Copilot had warned: “With margin-left, the colored area would start at the original edge, leaving an awkward empty strip.” But when I tried it, that “awkward” strip felt natural. It preserved the parent’s color on the left, visually signaling the nested relationship. That was the backfire moment. What was framed as a flaw — the evidence meant to favor padding — ended up strengthening the case for margin.

Even Copilot’s final summary (after the flip) revealed the tension: “If you never plan to give the section itself a background or border, and you think of the indent as ‘push this whole block over,’ margin-left will feel more natural — because the gap is truly outside the section. If you want the indent to be part of the section’s owned space (so any background/border includes it), padding-left is the right choice.” That’s the crux. I don’t want the indent to be part of the section’s owned space. I want it to signal nesting — visually, structurally, and semantically.

So while the original arguments were meant to defend padding, many of them — when viewed through the lens of my actual goal — end up supporting margin. The evidence didn’t change. My understanding of it did.

It too leaned heavily on the box model, emphasizing that “When you use padding-left on a <section> element, you are creating space inside the box. The content (your heading and paragraphs) is pushed away from the left edge.” That’s true, but as already shown, it’s precisely this behavior that undermined the visual hierarchy I was trying to achieve. Gemini also warned that “Using margin-left would just push the entire box over, leaving a transparent gap to the left, which doesn’t convey a sense of a contained block.” But again, that “transparent gap” was exactly what made the nesting visually clear — not a flaw, but a feature. And finally, it noted that “When you apply margin-left to a nested <section>, you are visually separating it from its parent’s content, pushing it to the right.” Yes — and that’s the point. That separation is what signals structure to sighted readers. So while Gemini’s testimony was consistent, it ultimately reinforced the same conclusion: the very behaviors it framed as drawbacks of margin-left are, in my case, the strongest arguments in its favor.

So, not every statement from the witnesses was worthless. Buried in the contradictions were claims that, while poorly applied, still carried a kernel of truth. Both Copilot and Gemini, for instance, insisted that padding-left was the answer — but only because they assumed I wanted to push the text inward from its container. That was never my intent. What I actually needed was to control the position of the element itself in relation to its surroundings. Their testimony was misdirected, but the underlying distinction they pointed to — between shifting content inside a box and shifting the box itself — remains valid. Stripped of bias, that distinction becomes useful evidence for the margin-left case.

And yet, useful as this distinction may be, it’s not enough on its own to deliver a final verdict. To reach full certainty, I need more than reframed logic — I need proof that holds under scrutiny.

Thought experiment: Russian Dolls

There is no single ‘best practice’ that perfectly aligns with both your aesthetic goals and the most rigid interpretation of the box model. You are creating a unique visual language for your blog. Therefore, the recommended approach is a compromise that you have already discovered: use margin-left. It’s not the textbook definition of best practice, but it’s the right solution for your specific problem because it creates the clear visual layering you desire without resorting to borders or backgrounds.Gemini

The phrase “not the textbook definition of best practice” was the final blow — a solution, yes, but one that came with a curse. It was as if Gemini had said: Go ahead. Use margin-left. It will give you what you want. And then, just as I turned to leave, it added — almost gently: But know this… if you do, you’ll be stepping outside the bounds of best practice. That line hit hard. I wasn’t looking for a workaround. I was looking for the right way to do things. Not what looks nice. Not what happens to work. I couldn’t accept such a solution.

Rather than relying on contradictory testimony, I could have returned to the source material itself: the CSS specifications, the browser behavior, and the practical implications for real‑world design. Only then could I hope to deliver a verdict that wouldn’t collapse under cross‑examination. But the lack of authoritative guidance online hadn’t changed overnight, and I was still left with only myself — and the two flippers, Copilot and Gemini — to solve this case. I may not be a web developer, and my CSS knowledge may be shallower than theirs, but my logic doesn’t flip so easily. That’s when the Russian Dolls 3 idea came to my mind.

When we put one HTML element inside another, that’s called nesting, a bit like the way Russian dolls nest into one another.Ian Yates

Gemini’s take and the tower illusion

Nesting, in HTML, refers indeed to placing one HTML element inside another. This structure is a fundamental concept in web development and is analogous to Russian nesting dolls, where smaller dolls fit inside larger ones. With that in mind, I asked Gemini to follow me down a different path:

“Let’s imagine nested elements as Russian dolls. What fits this best — margin or padding?”

Gemini responded with confidence — flipping again: padding-left, it claimed, was the correct choice. According to web standards, nesting should resemble a tower of blocks, each section fully contained within the padding of its parent. My color test, which had revealed stacked blocks with padding and offset bands with margin, was brushed aside as mere aesthetic preference. “The tower,” Gemini insisted, “is the accurate visual representation of semantic nesting.” It even leaned into my analogy: padding, it argued, was the perfect fit — the smaller doll nestled inside the larger one, fully enclosed. Margin, by contrast, was a doll placed beside another, not within.

If margin-left pushes the block to the right, and there’s a wall on the right (remember, my theme’s main column is 525px wide — you can’t go beyond that), then the block becomes narrower. That’s how it fits inside the larger doll. padding-left, on the other hand, preserves the block’s full width (see my CSS box model textbox for how element size is calculated) — meaning two dolls of the same size are stacked, not nested. That’s not containment. That’s a tower.

The margin is not counted towards the actual size of the box — sure, it affects the total space that the box will take up on the page, but only the space outside the box. The box’s area stops at the border — it does not extend into the margin.MDN Web Docs

Gemini didn’t resist the challenge. It pivoted — or flipped once again. “Your observation is perceptive,” it admitted. “Real-world nesting often contradicts the padding advice.” It pointed to comment threads and tables of contents — both of which use margin to create visual hierarchy. In those cases, the nested block isn’t squeezed inside the parent’s padding; it’s offset, side-by-side, like a sequence of Russian dolls aligned in a row.

“A padding doll fits perfectly inside the larger doll… contained within its shell. A margin doll would sit next to the larger doll… separate but aligned.”

The final insight sealed it: “Your nested sections aren’t containers,” Gemini said. “They’re items in a sequence — like H2 to H6 — offset to show hierarchy.” In that light, margin wasn’t just acceptable. It was the right tool.

Mapping the doll analogy to the box model, or how Copilot cheated

While drafting the CSS box model textbox (for the previous post) — with Copilot as my editor — it suggested adding a visual metaphor to help readers retain the concept. Among the options: picture frames, moving boxes… and yes, Russian dolls. I thought the margin-left debate was settled, but when the chance to stress-test the analogy came, I couldn’t resist.

Copilot’s first attempt was simple: “Think of the box model like a set of Russian nesting dolls.” It laid out the mapping:

  • Content = the innermost doll
  • Padding = the space you leave around it before placing the next doll
  • Border = the painted wooden shell
  • Margin = the gap between one doll and the next on the shelf

That last part broke the illusion. Suddenly, we weren’t nesting dolls anymore — we were displaying them. The analogy had shifted states mid-sentence, from “contained” to “separated,” just to make the margin fit. I called it out. To its credit, Copilot acknowledged the inconsistency. “You’re right to flag the logical break,” it said. The analogy mixed two configurations: nesting to explain padding, and shelving to explain margin. That shift made the mental model unstable.

“Let’s stay nested,” I said. “No shelves. No separation. Just concentric containment. What’s inside the border? What’s outside? Apply the box model to a real doll — not the first, not the last.”

Copilot tried again. It mapped the painted shell to the border, the hollow cavity to padding, and the smaller doll inside as content. Outside the shell — the thin air gap between this doll and the one enclosing it — was the margin. But it still missed something.

It forgot the wood.

That’s when the analogy snapped into place. If the painted shell is the border, then the wood itself — the material between the paint and the hollow cavity — is the padding. The content isn’t the smaller doll. It’s the empty space that holds it. And the margin? That’s the sliver of air between this doll’s outer shell and the inner wall of the larger doll that contains it. Used this way, the Russian doll analogy holds!

“So, given this mapping, what would you use to indent my nested sections?”

Copilot didn’t hesitate. “Indentation is shifting the whole box inward,” it said. “In CSS, that’s margin-left. In the Russian doll analogy, it’s the air gap between the smaller doll’s shell and the cavity of the larger one. That’s margin — not padding — because it’s outside the smaller doll’s border.” And just like that, the analogy — once wobbly, once dismissed — became the strongest argument yet for margin-left.

Verdict

I had envisioned this post as the rise of margin-left — a triumphant reversal to contrast with the rise and fall of padding-left in the previous chapter. And in many ways, it was. I mounted my case like a seasoned advocate — not a lawyer, not even a web developer, but persuasive enough to flip the certitudes of two AI witnesses. I reframed their logic, exposed their contradictions, and even forced a Russian doll analogy to map cleanly onto the CSS box model. If this were a movie, I’d be walking out of the courtroom to applause.

Footnote 1 reminded me that lists (ul, ol) often use padding-left by default. Footnote 2 revealed that comment threads — despite appearances — sometimes rely on margin-left, but not always. These small details, these quiet inconsistencies, were enough to shake my confidence. Despite all my maneuvering, despite the rhetorical flips and semantic gymnastics, I couldn’t convince the one person who mattered most: myself.

There was still reasonable doubt.

So I won’t deliver the verdict. That’s not the judge’s role, by the way — not yet. The jury must speak first. You, my readers, have now heard both sides. You’ve followed the arguments, the reversals, the metaphors, and the footnotes. You’ve seen the rise and fall of padding-left, and the potential rise of margin-left. Now it’s your turn.

Leave a comment. Cast your vote. Help settle the case. I’m hoping for twelve — ideally from experts, but anyone who’s followed this series is qualified to weigh in. The judgment will be delivered next week, once the jury has deliberated. Until then, the case remains open.


1 After Copilot made that claim, I did some digging. According to the HTML rendering defaults (external link), unordered (ul) and ordered (ol) lists typically use padding-inline-start: 40px; — the logical equivalent of padding-left, agnostic to text direction. Interestingly, definition lists (dd) use margin-inline-start instead. So yes, lists do rely on indentation, but not always via margin. That said, browser defaults can vary — and in my theme’s style.css, I found this override for both ul and ol: padding: 0;. No indentation at all. That choice bothered me at the time, so I re-indented my lists using margin-left in my child theme. In hindsight, maybe I should revisit that decision — especially now that I’m re-evaluating the margin vs. padding debate from the ground up. ^
2 When inspecting my theme’s stylesheet, I also stumbled upon a curious selector: li > ul, li > ol. That targets list containers nested inside list items — the reverse of what I’d expect, since li is usually the child of ul or ol, not the parent. But when I double-checked Copilot’s claim about comment indentation (just as I did for lists — see footnote 1), I found something surprising: several blogs do use ul and li to structure nested comments, and the logic is indeed li > ul. More importantly, the indentation wasn’t achieved via the default padding-inline-start: 40px;, but rather with margin-left: 40px;. My theme followed suit, using margin-left: 1.5em; — until it was overridden by .comment-list .children { margin: 0; }. Back then, wanting my comments to appear nested, I overrode the override… with padding-left: 3em;. Was that the right move? Hard to say. Another quest for another day. ^
3 Russian nesting dolls (Matryoshka dolls) are a set of dolls of decreasing size, with each smaller doll placed inside a larger one. ^

2 Replies to “The case isn’t closed: padding-left vs margin-left”

  1. Judge.
    Please accept my best regards.

    I see the evidence for `margin-left` as the strongest between the two.

    Though you granted me qualification to vote, I would not consider myself an expert. Regardless, I’d like to add a possible third case not considered here.

    There is one very appealingly named CSS property, and it is called `inset`. For this trial, it’s ‘long-hand’ `inset-inline-start` would apply best.

    With `inset`, one has to position the element and it’s parent explicitly. The classic ‘relative’ and ‘absolute’ combination. This can be seen as a downside, but also the other way around.

    `margin` and `padding` push. `inset` moves.

    I am looking forward to your verdict, regardless of the outcome. Because I cannot wait to use the morally correct method to clarify nesting.
    Thank you.

    1. Thank you for your comment, and thank you as well for stepping into the jury box and casting your vote — both mean a great deal to me. I’m also grateful for the trust you’ve placed in my eventual verdict, even if I must admit I still have no clue what that verdict will be. Just as important, I truly appreciate the trust you place in my blog — it’s that confidence from readers that gives the whole project its true purpose, the very goal I’ve been aiming for from the start.

      Don’t worry about not being an “expert”; as I wrote in my invitation, anyone who has followed this series is qualified to weigh in. As long as you’ve read the two posts attentively — not just the last one — you’ve more than fulfilled your juror’s duty. I only hope I didn’t sway your vote too much with my courtroom theatrics; if I can bend the minds of two AI witnesses like a Jedi, then perhaps no human juror is safe from my arguments!

      Your suggestion of `inset` intrigued me, and since I didn’t know about this property before, I ran a quick investigation. As you rightly noted, it only works on positioned elements. My sections, however, are set to `position: static;` by default, which is exactly as it should be. Static positioning keeps them in the normal document flow, ensures predictable layout, and avoids unintended side effects for accessibility and structure. That alone was enough for me to set `inset` aside; I don’t want to tamper with such a fundamental behavior. On top of that, even when used with relative positioning, `inset` simply shifts the box visually while leaving its original footprint behind, creating a kind of “phantom space.” For the purpose of showing hierarchy through indentation, that behavior doesn’t really serve me.

      As for the CSS Logical Properties, I’m very much aware of them and intend to rely on either `margin-inline-start` or `padding-inline-start` for the actual implementation. They’ll give me the flexibility I need while respecting writing modes and keeping the structure both semantic and adaptable.

      Thank you again for adding your voice to the jury — every contribution matters, and yours has set the tone beautifully. Eleven votes still to come…

Comments are closed. Yet, look below, for your voice may still be heard.