Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remember in CSS that margin is outside the border, and padding inside [closed]

I don't edit CSS very often, and almost every time I need to go and google the CSS box model to check whether padding is inside the border and margin outside, or vice versa. (Just checked again and padding is inside).

Does anyone have a good way of remembering this? A little mnemonic, a good explanation as to why the names are that way round ...

like image 498
Hamish Downer Avatar asked Aug 28 '08 16:08

Hamish Downer


People also ask

What do you called the space between padding and margin?

Border. The border is the layer of the CSS box model that sits between margin and padding. By default, the border does not have any width, but you can set one with the CSS border property.

What is the order of margin and padding in CSS?

When three values are specified, the first margin applies to the top, the second to the right and left, the third to the bottom. When four values are specified, the margins apply to the top, right, bottom, and left in that order (clockwise).

Is the margin or padding of an element inside the border?

The main difference between CSS padding and margin is that padding is the space between the element's content and border (within the element itself), while margin is the space around the border of an element.

Which property in CSS is used to represent a space or a margin to the outside border?

The CSS margin properties are used to create space around elements, outside of any defined borders. With CSS, you have full control over the margins. There are properties for setting the margin for each side of an element (top, right, bottom, and left).


1 Answers

When working with CSS finally drives you mad the padded cell that they will put you in has the padding on the inside of the walls.

like image 50
Simon Keep Avatar answered Sep 20 '22 08:09

Simon Keep