MyUserQuestion
MyUserQuestion

Reputation: 295

CSS set space between all internal html components

I need to set a 4px space between all html internal components (in any direction top bottom left right). I am using an external css file for this. I tried this:

body {
       padding: 2px;
       border: 0px;
       margin: 0px;
}

But this sets a space of 4px for all body not between it's components.

Also,

{
 display: inline-block;
 padding: 4px;
} 

is not working either.

Can you please help. I am not allowed to change the html page.

Upvotes: 1

Views: 1311

Answers (3)

cssGEEK
cssGEEK

Reputation: 1014

Maybe you can try padding like this:

body *{
padding:4px;
}

Upvotes: 0

Shelly
Shelly

Reputation: 351

Looks like you need to set for the elements used on HTML , if you are using Css preprocessor , then you can declare the values at the top and later it will be used by all the elements like shown below :-

 $standard-padding :2px;
 $standard-border:0px;
 $standard-margin:0px;

 body,p,h1,h2,div,span{ 
   padding: $standard-padding;
   border: $standard-border;
   margin: $standard-margin;
 }

Upvotes: 0

Álvaro Reneses
Álvaro Reneses

Reputation: 701

You can use

body * {
   margin: 2px;
}

Which will set that margin to every element inside of the body tag.

Upvotes: 3

Related Questions