0

I am new here and to the world of web development. Hope someone clear a confusion I am having for sometime.

when specifying the container within a body, why do I see others put display: block, isn't that already the default for the display? Why the need to specify it in the CSS? Also, what is the difference between margin: 0 auto and margin: auto. I know that the 0 will do the top & bottom, and the auto, the left and right but will setting only auto do all sides?

Thank you

ZeWorks
  • 89
  • 1
  • 6
  • when I say the default, I mean the default for a div. – ZeWorks Mar 01 '18 at 11:05
  • you can easily find your answer with a simply google search ... – Temani Afif Mar 01 '18 at 11:05
  • `margin: 0 auto` is setting margin-top/bottom to 0, and margin-left/right to auto. – Phiter Mar 01 '18 at 11:06
  • It's like `margin: y x` – Phiter Mar 01 '18 at 11:06
  • @TemaniAfif I know that display: block creates a block level element but I don't see why it's needed for a div, I feel like I am missing something. – ZeWorks Mar 01 '18 at 11:07
  • it's never need for a div ... but maybe you have other style overriding it so you added it agian to be sure it's block – Temani Afif Mar 01 '18 at 11:08
  • when writing CSS we don't leave things to hazard .. you want something to be block so you specifiy it even if it's the default behavior ... don't rely on default unless you are sure there is nothing else that will change this – Temani Afif Mar 01 '18 at 11:09
  • @TemaniAfif fair enough, I have been following tutorials and I kept seeing this come up but now I guess I see the point of not relying on the default. thanks. – ZeWorks Mar 01 '18 at 11:23

0 Answers0