+ 2

What is the difference between top and margin- top please explain with example

Problem

20th Jan 2018, 5:29 PM
adarsh sharma
adarsh sharma - avatar
3 Answers
+ 5
'top' is used together with 'position'. Example: CSS: div{ position:absolute; top:10px; left:10px; } HTML: <h1> paragraph </h1> <div> div tag </div> It positions the element 10px from top and 10px from left of the browser window . Overlapping the <h1> element. margin-top adds margin to the top of an element: div{ margin-top:10px; } this one adds 10px of space at the top of div and remains below the <h1> tag.
20th Jan 2018, 10:46 PM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar
+ 3
Please see questions care fully Thomas and tobias
20th Jan 2018, 6:31 PM
adarsh sharma
adarsh sharma - avatar
0
from my perseption, top is position property, while margin-top is own element property
14th Aug 2018, 7:55 AM
Ben Zabid
Ben Zabid - avatar