Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3395746
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:19:30+00:00 2026-05-18T04:19:30+00:00

I have had to work on a project that was written by someone else,

  • 0

I have had to work on a project that was written by someone else, and the way they wrote the site everything is positioned using margins, both positive and negative margins.

I only ever really use margins for textual elements like <p> or <h1> tags.

Using padding to space the contents within my div building blocks.

I have come across a lot of issues when margin has been used on divs to try and control the spacing of them.

So my question is:

Is it best practice to only use margins on textual elements, and use padding on the main building blocks unless it makes more sense to use margins on that particular case?

I am interested on other peoples opinions of the margin attribute and it’s uses.

Has it caused anyone else issues?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:19:31+00:00Added an answer on May 18, 2026 at 4:19 am

    The CSS margin attribute should be used to set gaps between boxes, not to position the text (content) inside a certain box and not to alter the positioning of a box. For each of these two activities there are specific properties: padding and position (with left, right, top, bottom).

    Deciding which of the properties you need is fairly simple. Lets take some cases:

    A. I have 3 columns inside a parent and I want them to have some space between them.
    This will require using margin because you clearly need space between the elements, not inside them.

    B. Each of the columns has a border and text content, but the text content starts right from the border. What do I do?
    You apply some padding. Even if you don’t have borders and want to position the text content, you still apply padding, and not margin!

    C. I want to make some cool futuristic layout, with boxes that aren’t aligned next to each other. Some of them should even overlap!
    In this situation it’s clearly not a problem of spacing, but one of positioning, so you should use the, you’ve guessed, position property. Don’t apply margin to space elements one from another, but rather position them relative to a parent (or to their default position if using position: relative).

    Tip: To make it easier to decide if you need margin or padding always think about what would you do if your you had borders on all elements.

    Mandatory reading: http://www.w3.org/TR/CSS2/box.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have had many requests come in to a project that I work on,
We have had SharePoint where I work for a little while now, but we've
I have had a bug recently that only manifested itself when the library was
What are some strategies that people have had success with for maintaining a change
I'm sure that all of us have had to deal with telecommuters at some
I'm working on an existing project that has a text import tool written in
I've got a medium scale project (a turn-based game) that's currently written in C/C++.
I have a project that adds elements to an AutoCad drawing. I noticed that
Have had to write my first proper multithreaded coded recently, and realised just how
I have had to do this several times, usually when trying to find in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.