Image size

Discussion in 'HTML & Website Design' started by MaryMach, Apr 6, 2013.

  1. #1
    I've always declared the image size in the img tag. Recently I've been told that's no longer necessary and as a matter of fact I should not add the height and width. Opinions?
     
    Solved! View solution.
    MaryMach, Apr 6, 2013 IP
  2. Skovy

    Skovy Greenhorn

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    23
    #2
    I always use CSS in an external style sheet to declare only the width of the image. Let the height of the image auto-adjust to the width so the image does not become distorted or anything.

    I would recommend putting only the width in your external CSS. This makes the image much more dynamic and flow with the rest of the page better.
     
    Skovy, Apr 6, 2013 IP
  3. #3
    Well, one has to first look at WHY it should be included... The reason it even exists in the first place is so that the size box in the layout is placed before the image is loaded. This was VERY important during the age in which people were using IMG tags to add presentational images like borders or icons in the markup, often in layout elements like tables. As the images loaded their sizes the layout would jump all over the place as it had to resize.

    Every one of those 'resizes' is called a 'reflow' -- the 'flow' of the page is redone top to bottom every time. Used to be reflows took a LONG time, the more images you had the more time it took. Setting the size prevented this.

    Now, presentational images go in the CSS, if at all. CSS background-images don't have size declarations, and the CSS layout just kind of pops into place all at once as a single flow.

    Having actual content images in your HTML reflow is far less disruptive than your layout/template images would be, and increases in bandwidth allow the information like sizes of the images and even the images themselves to quickly load - So it is often safe now to omit them... I rarely bother anymore.

    The only time I'd manually state the size is if it's a really large slow loading image that would disrupt the placement of content around it. Generally speaking I don't believe in putting images of that nature on a page in the first place; thumbnail linking to the full size image being the proper practice -- no matter what the idiots placing the massive banners across the top of their sites forcing them to have a fixed width layout will try to tell you.

    So it really comes down to the images themselves. Since layout images and presentational images have NO business in a IMG tag as of 1998, (or should I say common practice from 2003 onward) it's really not a big deal to leave out the width and height attributes on the actual content images anymore.

    BUT, if you're still sleazing out HTML 3.2 and slapping 4 tranny or 5 lip service around it, using tables with presentational images in them to make your fancy borders... You better keep using them.
     
    deathshadow, Apr 6, 2013 IP