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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:36:07+00:00 2026-06-02T08:36:07+00:00

CSS/HTML problem. This is crazy – I can only assume that I am an

  • 0

CSS/HTML problem.

This is crazy – I can only assume that I am an idiot. I cannot make my image fill the div it is in. There is consistently 5px “padding” beneath the image.

Here is the html:

<!doctype html>

<head><link rel="stylesheet" href="style.css" type="text/css" /></head>

<body>
<div class="row">
<img src="pic2.jpg" />
</div>
</body>

And here is the CSS:

body, .row, img {
padding: 0;
margin: 0;
border: none;
}

.row {
width: 80%;
background-color: orange;
}

img{
width: 50%;
}

This is the result:

https://i.stack.imgur.com/7Qyk8.jpg

As you can see, the (stupid) blue and red image does not fill the orange div. There is a consistent 5px of orange showing beneath the image. This isn’t affected by changes to the % widths of the div or the image, or by resizing the window.

I can fix this with “margin: -5px;”, but I want to know why it is happening (especially if under different circumstances the amount is more or less than 5px).

Thanks for your help (and sorry again if this is a ridiculous error on my part).

  • 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-06-02T08:36:10+00:00Added an answer on June 2, 2026 at 8:36 am

    Add a vertical-align value (other than the default baseline) to your image like: top, middle…

    vertical-align: top;
    

    Example:

    /* QuickReset */ *, ::after, ::before { margin: 0; box-sizing: border-box; }
    
    .row {
      background-color: orange;
    }
    
    img {
      vertical-align: middle;    /* or top, bottom, ...  */
    }
    <div class="row">
      <img src="https://www.gravatar.com/avatar/69cfcc1895204718647d030c5e887cbe?s=64&d=identicon&r=PG" />
      <span>Some text</span>
    </div>

    Alternatively, you could make your parent display set to: flex, inline-flex, or grid – if that fits your needs

    /* QuickReset */ *, ::after, ::before { margin: 0; box-sizing: border-box; }
    
    .row {
      background-color: orange;
      display: flex;
      align-items: center;
    }
    <div class="row">
      <img src="https://www.gravatar.com/avatar/69cfcc1895204718647d030c5e887cbe?s=64&d=identicon&r=PG" />
      <span>Some text</span>
    </div>
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a CSS/HTML submit form that I am going to make
i'm experiencing the weirdest positioning problem that appears only in firefox. My HTML: <article
I am currently at a loss with this particular bit of HTML/CSS problem. I
I got a problem like this (this is html/css menu): Eshop | Another eshop
I have an alignment problem in html/css. I simplified my problem to this: <!DOCTYPE
$(this).parent().parent() .children(this.attr(tagName).toLowerCase()) .css(background-color, yellow); xpath: /html/body/div/table/tr/td/b/a $(this).tagName is Anchor <a> the problem with this
I have a strange problem working with HTML,CSS in different browsers: Firefox 3.6 and
I have a weird problem with my HTML and CSS code: <header> <h1>title</h1> </header>
I have the following html/css that is causing problems in Firefox 1.5 and 2,
I'm coding a tab system for my website that must be entirely CSS/HTML/JS (without

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.