Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A few extra pixels of height - where could they be coming from?

Tags:

On, e.g., this link: http://4ad.com/releases/20949, if you look at the album cover image in the top right part of the page, the black border is not quite square: there are a few extra pixels of height at the bottom.

As far as I can tell the image is 300x300 pixels in size. There are no obvious (to us!) sources of the extra 4.5 pixels of height. Does anyone know what could be creating such a discrepancy?

like image 391
thesunneversets Avatar asked Jun 30 '11 19:06

thesunneversets


People also ask

How you can define the height of the image in pixels?

The height attribute specifies the height of an image, in pixels. Tip: Always specify both the height and width attributes for images. If height and width are set, the space required for the image is reserved when the page is loaded.

What property help you to set size of element?

The height and width properties are used to set the height and width of an element. The height and width properties do not include padding, borders, or margins. It sets the height/width of the area inside the padding, border, and margin of the element.

What is in CSS sizing?

The size CSS at-rule descriptor, used with the @page at-rule, defines the size and orientation of the box which is used to represent a page. Most of the time, this size corresponds to the target size of the printed page if applicable.


2 Answers

Since the image is inline, it's treated as text, which means a few extra pixels are added to the bottom as leading. Displaying the image as a block (i.e. adding display: block;) solves the problem nicely.

like image 52
You Avatar answered Feb 19 '23 11:02

You


By default, images are displayed as inline-block and aligned with the baseline of the text. The extra space is added for Descenders.

To fix it, use vertical-align: top or middle or bottom on the img. See http://jsfiddle.net/Gu6pG/3 for the difference.

like image 20
user123444555621 Avatar answered Feb 19 '23 13:02

user123444555621