image size specification: optional?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Haines Brown

    image size specification: optional?

    I'm in the practice of specifying img width and height in my style
    definitions, although I usually use the actual size of the image. I'm
    reworking the style and it would be convenient to leave image size
    unspecified unless I need to change its dispayed size.

    What, if any, are the reasons why an image size should be specified in
    a stylesheet if it will be displayed in its actual size?

    --
    Haines Brown

  • Mark Tranchant

    #2
    Re: image size specification: optional?

    Haines Brown wrote:
    [color=blue]
    > I'm in the practice of specifying img width and height in my style
    > definitions, although I usually use the actual size of the image. I'm
    > reworking the style and it would be convenient to leave image size
    > unspecified unless I need to change its dispayed size.
    >
    > What, if any, are the reasons why an image size should be specified in
    > a stylesheet if it will be displayed in its actual size?[/color]

    Because the image may be downloaded after the main content. By
    specifying the size, the browser knows how much space to leave for it.

    If it doesn't know, other content may be moved around after loading to
    accommodate the image. If your user is halfway through reading the first
    paragraph only to have all the text shift around, it can be very
    distracting.

    Why not put it in the <img> tag? I don't see that as presentational
    markup - it is a property of the image file.

    --
    Mark.

    Comment

    • Spartanicus

      #3
      Re: image size specification: optional?

      Haines Brown <brownh@teufel. hartford-hwp.com> wrote:
      [color=blue]
      >I'm in the practice of specifying img width and height in my style
      >definitions, although I usually use the actual size of the image. I'm
      >reworking the style and it would be convenient to leave image size
      >unspecified unless I need to change its dispayed size.
      >
      >What, if any, are the reasons why an image size should be specified in
      >a stylesheet if it will be displayed in its actual size?[/color]

      Image dimensions should normally be specified in the markup. As always,
      CSS is optional and the purpose of specifying dimensions for
      embedded/replaced content is to allow the UA to layout a page before the
      dependencies have finished downloading, or perhaps the UA is configured
      not to load the dependencies at all.

      --
      Spartanicus

      Comment

      • Neal

        #4
        Re: image size specification: optional?

        On Thu, 05 Aug 2004 13:46:28 GMT, Haines Brown
        <brownh@teufel. hartford-hwp.com> wrote:
        [color=blue]
        > I'm in the practice of specifying img width and height in my style
        > definitions, although I usually use the actual size of the image. I'm
        > reworking the style and it would be convenient to leave image size
        > unspecified unless I need to change its dispayed size.
        >
        > What, if any, are the reasons why an image size should be specified in
        > a stylesheet if it will be displayed in its actual size?[/color]

        By omitting the height and width of an image in the HTML, the browser
        cannot leave sufficient space for the image when the page is rendered
        before the image is downloaded. As a result, the visitor experiences
        distracting and annoying jumping around while the image loads.

        I do not think it's wise to leave this out of the HTML. Perhaps there is a
        PHP solution where the image element is generated based upon the
        properties of the image to be included, but I have insufficient knowledge
        of PHP to advise on this. Short of this, the only way to dependably let
        the UA allow proper space for the image while rendering is to use the
        height and width attributes in the image element.

        CSS should always be viewed as an optional enhancement of the HTML
        content. Pages which cannot function without CSS are not properly designed.

        Comment

        • Harlan Messinger

          #5
          Re: image size specification: optional?


          "Neal" <neal413@yahoo. com> wrote in message
          news:opsb9lo8ku 6v6656@news.ind ividual.net...[color=blue]
          > On Thu, 05 Aug 2004 13:46:28 GMT, Haines Brown
          > <brownh@teufel. hartford-hwp.com> wrote:
          >[color=green]
          > > I'm in the practice of specifying img width and height in my style
          > > definitions, although I usually use the actual size of the image. I'm
          > > reworking the style and it would be convenient to leave image size
          > > unspecified unless I need to change its dispayed size.
          > >
          > > What, if any, are the reasons why an image size should be specified in
          > > a stylesheet if it will be displayed in its actual size?[/color]
          >
          > By omitting the height and width of an image in the HTML, the browser
          > cannot leave sufficient space for the image when the page is rendered
          > before the image is downloaded. As a result, the visitor experiences
          > distracting and annoying jumping around while the image loads.
          >
          > I do not think it's wise to leave this out of the HTML. Perhaps there is a
          > PHP solution where the image element is generated based upon the
          > properties of the image to be included,[/color]

          The browser doesn't interpret HTML differently depending on whether it's
          hard-coded or generated by server-side code.

          Comment

          • Haines Brown

            #6
            Re: image size specification: optional?

            Mark Tranchant <mark@tranchant .plus.com> writes:
            [color=blue]
            > Haines Brown wrote:
            >[color=green]
            > > I'm in the practice of specifying img width and height in my style
            > > definitions, although I usually use the actual size of the image. I'm
            > > reworking the style and it would be convenient to leave image size
            > > unspecified unless I need to change its dispayed size.
            > > What, if any, are the reasons why an image size should be specified
            > > in a stylesheet if it will be displayed in its actual size?[/color]
            >
            > Because the image may be downloaded after the main content. By
            > specifying the size, the browser knows how much space to leave for it.[/color]
            [color=blue]
            > Why not put it in the <img> tag? I don't see that as presentational
            > markup - it is a property of the image file.[/color]

            Thanks, Mark. Based on your advice and that of others, I've restored
            the size declaration for img.

            --
            Haines Brown

            Comment

            • Claire Tucker

              #7
              Re: image size specification: optional?

              On Thu, 5 Aug 2004 12:58:14 -0400, "Harlan Messinger"
              <h.messinger@co mcast.net> wrote:[color=blue]
              >
              >"Neal" <neal413@yahoo. com> wrote in message
              >news:opsb9lo8k u6v6656@news.in dividual.net...[color=green]
              >>
              >> I do not think it's wise to leave this out of the HTML. Perhaps there is a
              >> PHP solution where the image element is generated based upon the
              >> properties of the image to be included,[/color]
              >
              >The browser doesn't interpret HTML differently depending on whether it's
              >hard-coded or generated by server-side code.
              >[/color]

              I have a feeling that what Neal was getting at was to generate the
              page by some dynamic means and then have the software locate the image
              file on disk and read its header to find its width and height to
              include in the image element before generating it.

              This seems a little like overkill to me, but there's not really any
              reason why it *couldn't* work. (assuming the images are actually
              stored as files on disk)

              -Claire

              Comment

              • Brian

                #8
                Re: image size specification: optional?

                Mark Tranchant wrote:
                [color=blue]
                > Haines Brown wrote:
                >[color=green]
                >> What, if any, are the reasons why an image size should be specified
                >> in a stylesheet if it will be displayed in its actual size?[/color]
                >
                > By specifying the size, the browser knows how much space to leave for
                > it.
                >
                > Why not put it in the <img> tag? I don't see that as presentational
                > markup - it is a property of the image file.[/color]

                I agree that one should include dimensions in the HTML, unless the image
                is very small and includes text in the alt attribute value. In such
                cases, it is best to leave dimensions out so that users will be able to
                read the alt text.

                --
                Brian (remove ".invalid" to email me)

                Comment

                Working...