Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7714543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:09:19+00:00 2026-06-01T02:09:19+00:00

I’m struggling to determine where in my CSS the padding/margins should go to keep

  • 0

I’m struggling to determine where in my CSS the padding/margins should go to keep seperation between parent and child containers. For example, if you have have a parent div with two nested children and you need to have even 10px spacing between the children and also have the children be spaced 10px from the parent; then would you add padding to parent div {padding:10px} and then just add 10px of margin between the children? Or would you leave the parent at 0 padding and have the children define what separation they need from each other and also their parents?

Here’s the original fiddle showing both examples, and a snippet showing the same thing

.parent1 { /*spaces itself from its children*/
    display: inline-block;
    padding: 10px;
    font-size: 0;
    border: 1px solid red;
}
.child1 {
    display: inline-block;
    margin-right: 10px;
    font-size: 12pt;
    border: 1px solid blue;
}
.child2 {
    display: inline-block;
    font-size: 12pt;
    border: 1px solid green;
}
.parent2 { /*has not spacing from its children*/
    display: inline-block;
    font-size: 0;
    border: 1px solid red;
}
.child3 {
    display: inline-block;
    margin: 10px;
    font-size: 12pt;
    border: 1px solid blue;
}
.child4 {
    display: inline-block;
    margin-right: 10px;
    font-size: 12pt;
    border: 1px solid green;
}
<div class="parent1">
    <div class="child1">child1</div>
    <div class="child2">child2</div>
</div>
<br/>
<br/>
<div class="parent2">
    <div class="child3">child3</div>
    <div class="child4">child4</div>
</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T02:09:21+00:00Added an answer on June 1, 2026 at 2:09 am

    For me it depends entirely on the semantic meaning of the nodes in question — what is the parent, what are the children?

    Does the parent “want” space within it to keep its content away from its borders (padding)? Or do the children “want” distance between and amongst themselves and their parent (margin)?

    The answers to those questions are based on the purpose each node serves (I’m big into semantic markup and avoid presentational markup)

    In your case, without knowing further meaning, it sounds like the children want to be 10px from everything, so I would give them margin: 10px; on all sides. The margin collapse between the two children would leave only the 10px gap there, and they’d be 10px away from everything else surrounding them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.