The CSS Default Box Model is Utter Madness: A Parable


why on brick

SCENE: A housing development.

–Thanks for coming over. Are you the foreman for Constructing Stylish Sanctuaries, LLC?

–Our name’s a mouthful. Just call us “CSS” for short.

css box model example–Great. Well, as you can see, I’ve just bought this brand-new plot of land. It’s just green grass now, but soon it’ll contain my home, garage, and a lot of other elements.

It’s square, 100 feet on each side, with two plots bordering it. The three plots are enclosed by streets on all four sides.

–And how can we style this plot for you?

–Well, I’m not yet ready to start building my house or any of the other things I know will go inside the plot, so I just want help with the two things I do know.

css box model exampleFirst, I’d like a nice hedge around my property. My favorite shrubs grow to about five feet thick, so please plan on that.

–So the plot’s got a five-foot border.

–Exactly.

css box model exampleAnd the second thing is that I want to keep a nice, big lawn all around the house. You can start to dig up the inside of the plot where you’ll pour the foundation, but please leave 20 feet on every side that you don’t touch.

–Okay, so you want us to give the plot 20 feet of padding?

–Sure, if that’s what you call it.

–We’ll start right away.

–You don’t have any questions?

–Nah, we’re CSS. We were started by a consortium of experts. It’ll be fine.

 

[Later…]

–Just checking in on the work. How’s it going?

–Oh, work’s going great. A word to the wise, though: your neighbors are psychopaths. We’re out there just doing our jobs, and they start screaming and threatening to call the cops.

–Really? I had no idea.

–Yeah, seems some people just don’t like having their yards dug up.

–Huh?

css box model example–We were digging a trench through your neighbor’s yard for the five-foot border, and she just lost it. Hate to see that.

–Wait, you built my hedge on her property?

–Sure. Same thing on the other side. And we also tried to dig up both streets that border your plot, but the asphalt keeps gumming up our machines.

–You tore up the road?

–Yeah, real headache. Luckily we’d already dug up all 100 feet of your plot.

css box model example–The whole plot? What about the padding I asked for?

–It’s still there—it’s the first 20 feet of your neighbors’ yards, and of the streets bordering the house.

–That’s not where I wanted it! Why on earth would you try to build in spaces that belong to someone else?

–Hey, you should be grateful: getting that padding was like pulling teeth. Your one neighbor kept trying to park her car inside the space before we bulldozed it, and your other one kept ranting about his kids’ swing set, before we bulldozed that too. And of course, none of this could get done without a whole lot of screaming and weeping hysterically and throwing kitchen knives. Bunch of animals. We don’t get paid enough for this.

–This is a disaster! You’ve completely ruined the layout of this entire neighborhood.

–Don’t blame us. You didn’t tell us your plot was really 150 foot square.

–It’s not! It’s a 100-foot plot! I even took the time to specify those dimensions—I obviously meant for them to stay constant. Everything I told you to do was supposed to fit inside the plot!

–Huh—you’ve clearly never spoken to our consortium of experts.

FIN

Thanks for reading! For a technical discussion of the CSS box model, and for how to restore sanity to your layouts, see our follow-up post.

Image Credits: Ksayer1

3 thoughts on “The CSS Default Box Model is Utter Madness: A Parable

  1. Mik Fielding

    LOL! This is about the one and only thing I can think of that Internet Explorer got right. It’s original box model, as some folks may remember, kept the outer dimensions fixed and subtracted borders and padding from the INSIDE of the box rather than add them to the outside. I have never been able to figure why this didn’t become the accepted model …

    Reply
  2. Pingback: How to Do the CSS Box Model Right | Press Up

  3. Pingback: What’s Wrong with the CSS Box Model, and How to Fix It | Tutorial Store

Leave a Reply

Your email address will not be published. Required fields are marked *