What Are The 3 Ways By Which Margins Can Be Set Over A Div Using CSS? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What Are The 3 Ways By Which Margins Can Be Set Over A Div Using CSS?

Put up the rules / stylings / codes by which it can be done.

31st Oct 2017, 11:41 AM
🅹🅾🅽🅰🆃🅷🅰🅽 𝔸𝕕𝕠𝕜𝕨𝕖𝕚 🏅
🅹🅾🅽🅰🆃🅷🅰🅽 𝔸𝕕𝕠𝕜𝕨𝕖𝕚  🏅 - avatar
3 Answers
31st Oct 2017, 12:16 PM
visph
visph - avatar
+ 7
That was because of your "3 ways": I was thinking you're possibly be confusing (as a lot of people) between margin/padding (and transparent border could be the 3rd "ways" to set margin ^^ (notice that I previously wrote: "maybe" ;)) So, maybe you ask for the different shorthanded css notation? (but there's 4, in this case ;P) /* with only one value, apply for top, right, bottom and left */ margin: 10px; /* with two values, first one is for vertical (top and bottom), second for horizontal (left and right) */ margin: 10px 20px; /* with three values, first for top, second for horizontal (left and right), third for bottom */ margin: 10px 20px 30px; /* with four values, the order is from top and clockwise turn: top, right, bottom, left */ margin: 10px 20px 30px 40px;
31st Oct 2017, 6:01 PM
visph
visph - avatar
0
That's an interesting demonstration @visph, but I wasn't asking of the differences between MARGIN, PADDING & BORDER. You can refer to the question again. :)
31st Oct 2017, 4:42 PM
🅹🅾🅽🅰🆃🅷🅰🅽 𝔸𝕕𝕠𝕜𝕨𝕖𝕚 🏅
🅹🅾🅽🅰🆃🅷🅰🅽 𝔸𝕕𝕠𝕜𝕨𝕖𝕚  🏅 - avatar