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 7172013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:31:43+00:00 2026-05-28T15:31:43+00:00

I have a div that contains a paragraph, a list and a right-floated div.

  • 0

I have a div that contains a paragraph, a list and a right-floated div.

The parent div has a text-align:justify; property.

I am giving the p an (all-around) margin of 20px, but for some strange reason, the margin gets ignored on the right side of the paragraph. I tried it on the ul and the same thing happens.

The margin is not ignored if I do not justify the text inside the parent div. (But I do want it justified).

The floated div has a margin:0; so I guess this is not a collapsing margins issue.

The floated div is a fixed dimension (pixels) div and it is empty, except for a background image.

I also tried to specify the margin by margin-right:20px; and it did not work…

I know I could resolve it by just adding a left margin to the floated div. But I would like to know what is happening.

Here’s the code I’m using (I only edited the class names).

The CSS:

.parentDiv {
    position: absolute;
    width: 660px;
    height: 350px;
    z-index: -1;
    background-color:#4F4F4F;
    color:#FFFFFF;
    text-align:justify;
    overflow:hidden;
}

.foatedDiv {
    float:right;
    height:100%;
    margin:0;

}

.parentDiv p {
        margin:20px;
}

The HTML:

<div class="parentDiv">
 <div class="floatedDiv" style="width:234px;background-image:url(images/jp01.jpg)"></div>

  <strong><a href="someAnchor">Anchor</a></strong>

  <p>Sope paragraph that I cannot understand why ignores its right margin and is driving me crazy.</p>

  <strong>Some Topic</strong>

  <ul>
     <li>Some long item long enough to show there is no right margin.</li>
     <li>Some long item long enough to show there is no right margin.</li>
     <li>Some long item long enough to show there is no right margin.</li>
     <li>Some long item long enough to show there is no right margin.</li>
  </ul>
</div>

And this is what I get:

some nice alt text here

  • 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-28T15:31:44+00:00Added an answer on May 28, 2026 at 3:31 pm

    Because that image on the right side is floated to the right. It is applying your margin, you just can’t tell. That paragraph actually expands all the way to the right under that image, just the content box doesn’t. Your margin-right needs to be the width of that image plus 20px in order to indent it out 20px from the image.

    What your margins actually look like:

    example

    While the floated element pushes your content to the left, the actual physical box still expands behind that. To push the content out more, you have to account for all that space taken up by the image. One way to do that is to add it’s width to your margin on the right, like this:

    .parentDiv p {
        margin: 20px 254px 20px 20px; /* 234 + 20 = 254 */
    }
    

    See the solution on jsFiddle.

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

Sidebar

Related Questions

I have a div that contains inside 3 'floated' divs. The containing div has
I have a div that contains some text and the div has a background
I have a div that contains a list of messages (it's a chatroom application).
(The target browser is IE8) I have a div that contains a list of
I have a div that has a background colour and it also contains an
I have a div that contains many floated child items. Each child item is
I have a div that contains a large amount of text. I have set
i have a div that contains some text and i want to display it
I have a DIV that contains many input text. I need a way in
So I have a div that contains a block of text, previously the user

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.