Div inexplicably stretches in height

Here is an example of some markup:

<div class="account-picture">
    <img src="http://i.imgur.com/Mcr3l.png">
</div>

The div should be floated to the left and the image size is 128px x 128px.

Below is the CSS that goes along with it:

.account-picture{
   float: left;
   background: #FFFFFF;
   padding: 10px;
   border: 1px solid red;
   font-size: 1px;
   overflow: hidden;
}

img{
   border: 1px solid #F8F8F8;
   overflow: hidden;
}

There seems to be some mystery height being added to the div element. The height inconsistencies can be seen in the following layout diagrams when inspected using Firebug:

Why does the height of the div have additional pixels? And why does it vary between different browsers?

  • Firefox 12: 2px extra
  • IE9: 0.26px extra
  • Chrome: 0px extra

For further investigation, a JSFiddle has been provided here: http://jsfiddle.net/mWe5Y/

If you know the reason behind this issue and how to remove the extra height, please let me know!

Answer №1

Due to the nature of an inline element, that is why this occurs.

To eliminate the unnecessary height, follow these steps:

.profile-photo img {
    display: block;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the reason behind the inability of this YouTube instant search script to enable fullscreen mode?

Looking to implement a Youtube instant search on my website, I came across this script that seems ideal for my needs. However, I'm facing an issue where the iframe is not displaying the allowfullscreen property. Can anyone assist with this problem? Th ...

Audio in A-Frame does not function properly when in VR mode

My friend and I are collaborating on a small project involving a VR simulation that requires audio instructions. While everything functions smoothly in the web version and even on mobile devices, we encountered an issue when switching to VR mode on mobile ...

Trouble with Div Display

I have a section below my form that will show an alert message if there is an error. The issue I am facing is that if I use the inline-block property, everything within the section will be displayed in the alert color. I specifically want the background- ...

How can I ensure that a button remains fixed at the bottom of a Material UI React Component?

I am currently working on developing a layout for a web application, and I have encountered an issue that I am struggling to resolve. The structure of my grid is as follows: https://i.sstatic.net/TEU2a.png My goal is to ensure that each section inside t ...

Troubleshoot: Bootstrap Table Alignment Problem

I've been struggling to align my table header and content properly, as shown in the image. I want the header aligned to the right while keeping the rest of the content aligned to the left of the header. Is there a way to achieve this using only CSS wi ...

Unable to interact with element within an iframe during automated testing

I've been struggling with this issue for two days now and I just can't seem to solve it. I'm working on an automation Proof of Concept project (although I doubt I'll get the job) where I need to automate a task on an Oracle page. The p ...

retrieve data with the help of DOMDocument

I'm currently working on extracting a specific value from the HTML snippet below using DOMDocument: <h3> <meta itemprop="priceCurrency" content="EUR">€ <meta itemprop="price" content="465.0000">465 </h3> The value ...

Combining data from an API using Vue for seamless integration

I need to extract data from an API, such as imdbID, and then append ".html" to it in order to create a variable that can be placed inside the href attribute of a button. However, I am facing difficulties in achieving this. Thank you in advance for your hel ...

Add a class when there is no content available

I am trying to determine if the src attribute of an img tag is empty, and then add a class to another element. Below is the HTML snippet: <span class="page-icon"><img src="" width="40" height="40" alt="Privacy" /></span> If the src att ...

Using a MySQL statement within a conditional statement

Looking to modify this code to display different information based on the values retrieved, here is the current code: $sql_doublecheck = mysql_query("SELECT * FROM adminpage WHERE setting='main' AND close_site='1'"); $doublecheck = mys ...

Struggling to locate the Twitter direct message input box with Xpath in Selenium

I have been struggling to locate the textbox element using the find_element_by_xpath() method. Unfortunately, every time I try it, I receive an error stating that the element cannot be found. Here is the specific line of code in question: Despite attempti ...

When using my webrtc technology, I configure my sdp to establish a recvonly direction

While attempting to make a video call using WebRTC, I encountered bugs during testing. My goal is to integrate this project into a webview for my Android app. I conducted testing using phone-pc and phone-phone scenarios. Scenario A: When the PC initialize ...

What is the reason that object-fit does not affect the width or height?

I am facing an issue with an image in a div where the image is not resizing properly when using object-fit: contain. The width of the image remains unchanged, causing padding to appear around it. https://i.stack.imgur.com/D0wym.png Is there a way to make ...

The local sending time from the frontend to the backend automatically adjusts and is reduced by 2 hours

When using the DateTime-local in the HTML field to collect datetime from users, I noticed that when sending it to the backend to create an XML file, the date is automatically subtracted by 2 hours for some reason. Despite not making any alterations, and b ...

Unable to remove the white space appearing below and after a div in HTML

I have been working on creating a website. You can find my JSFiddle here. On my JSFiddle, you might notice a white gap above the black image labeled INSURANCE, and another white gap below it. I've tried various solutions but haven't been able to ...

Exploring the capabilities of XPath in Selenium

I am looking to create an xpath expression for the following sequence : Navigate to au.support.tomtom.com Click on the Flag icon in the footer. Select Australia as the country So far, I have attempted the following: driver.get("http://au.support.tomt ...

When I click on .toggle-menu, I want the data-target to have a toggled class and the other divs to expand

Looking to achieve a functionality where clicking on .toggle-menu will toggle a class on the specified data-target element and expand other divs accordingly. jQuery(document).ready(function() { var windowWidth = jQuery(window).width(); if (win ...

Difficulty arises when collapsed text in Bootstrap clashes with the footer design

Hey there! I'm working on this website using Bootstrap, and I've encountered a problem. When you click the "See Wikipedia" button, the content expands and overlaps the footer in a strange way without changing the page height. I've tried adju ...

Creating Table Rows on-the-fly

Seeking assistance and guidance from the community, I have modified code from an online tutorial to allow users to dynamically add rows to a table when data is entered in the row above. However, I am facing an issue where I can only insert one additional ...

Is it possible to display the footer only when I scroll to the very bottom of the page using ScrollMagic?

After browsing through numerous questions on StackOverflow similar to this one, I attempted various solutions but unfortunately, nothing seemed to work for me. :( Greetings! My current setup involves utilizing a MVC model in PHP. I'm incorporating ...