Search code examples
cssmedia-queries

margin/Padding or Position , which one is best for the responsive design?


I am always confused which one I should choose whether margin or position(relative, absolute) in making a web page responsive.

For example , I have an HTML element , now to align it properly, I can go for either margin/padding or Position, but I always think that which will be better to use so that I don't have to write lot of media queries for different devices .

Any help/advice is aprreciable !!!


Solution

  • Position is not better for responsive design. It is useful but not recommended to use in place of margin/padding.

    For example when you use position:absolute; on an element it takes that element out of normal content flow and adjusts its position only according to it's relative positioned parent element. If you use it too often, it is gonna create problems for you.

    And responsive design is about using float

    In short position is not to be substituted formargin/padding.