Html/css question . margin-top only works if padding-top exists?

In the following code if ‘padding-code:15px’ is removed then the line ‘margin-top’ (in #main-nav) stops having any effect whatsoever. why ?
Please analyze the code carefully. I am soo frustrated right now.

ok it does have an effect , but not the expected effect of giving main-nav a margin