+ 3

CSS Properties

Is there a difference between top,left,rigth,bottom properties and margin-top,margin-left etc.? Like I tried using them both and they had the same effect. I want to know if one is meant for a specific purpose or something

1st Jun 2018, 9:45 PM
Jax Wang
Jax Wang - avatar
6 Réponses
+ 2
The top, right, bottom, and left properties are generally used to move the element within whatever has been specified by the position property. The margin-left, margin-right, etc. properties are used to add a certain amount of space relative to the element, extending its box outwards. Hope this helped! d:
1st Jun 2018, 10:02 PM
Faisal
Faisal - avatar
+ 2
so you mean there can be only an effect for top, left, right, bottom if the position property of the element is specified?
1st Jun 2018, 10:04 PM
Jax Wang
Jax Wang - avatar
+ 2
ohh okay thankyou for your time!
1st Jun 2018, 10:07 PM
Jax Wang
Jax Wang - avatar
+ 1
Jax Wang Yep. They are quite highly dependant on it, so excluding it would render them useless
1st Jun 2018, 10:06 PM
Faisal
Faisal - avatar
+ 1
Well Faisal is right if you take a look at CSS Box Model you'll note that margins are beyond reach of those simply top ,right, left,bottom things
1st Jun 2018, 10:11 PM
Scorpia Rising🎩
Scorpia Rising🎩 - avatar
0
No problem ;)
1st Jun 2018, 10:08 PM
Faisal
Faisal - avatar