img without src= (?!)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alan J. Flavell

    img without src= (?!)


    For quite some other reason, I was looking at the source of a Google
    response page (which by the way contains some horrible SGML-related
    syntax errors), and was a bit surprised to find some <img> tags with
    no src= attribute. They also show up in Mozilla's View->Page
    Info->Media display, in that they have Type "Image" but the "Address"
    column is empty.

    They use them like this:

    <td height=7><img width=1 height=1 alt=""></td>

    and/or this (invalid syntax but for a different reason):

    <td bgcolor=#3366cc ><img width=1 height=1 alt="">

    What do the team think?

    OK, I have been known to resort to <td ...>&nbsp;</td> in the past,
    but I don't think I'd really want to do that.
  • Philipp Lenssen

    #2
    Re: img without src= (?!)

    Alan J. Flavell wrote:
    [color=blue]
    >
    > For quite some other reason, I was looking at the source of a Google
    > response page (which by the way contains some horrible SGML-related
    > syntax errors),[/color]

    Google never paid much attention to the HTML they produce (which is
    somehow weird considering they parse so much HTML for a living -- then
    again, maybe all the HTML they parse convinced them it's all a mess
    anyway).
    Exception to Google's HTML mess is Blogger.com, which at gives it a try
    (though it didn't validate throughout last time I checked... they are
    using an XHTML doctype).
    [color=blue]
    >
    > They use them like this:
    >
    > <td height=7><img width=1 height=1 alt=""></td>
    >
    > and/or this (invalid syntax but for a different reason):
    >
    > <td bgcolor=#3366cc ><img width=1 height=1 alt="">
    >
    > What do the team think?
    >[/color]

    OK, I *believe* they somehow use this to track clicks. Note the
    JavaScript function "ga()" on top of every search result page. I wrote
    something on the issue a while ago but they changed their functions.
    <http://blog.outer-court.com/archive/...#1087207954423
    88035>

    Whatever they do I'm certain every little tag means gigabytes (?) of
    traffic. I could be wrong.

    --
    Google Blogoscoped
    A daily news blog and community covering Google, search, and technology.

    Comment

    • Jukka K. Korpela

      #3
      Re: img without src= (?!)

      "Alan J. Flavell" <flavell@ph.gla .ac.uk> wrote:
      [color=blue]
      > - - I - - was a bit surprised to find some <img> tags with
      > no src= attribute.[/color]

      Interesting. In principle, should we say that such elements have well-
      defined rendering, if an alt attribute is present? After all, since there
      is no image to be shown, a browser must, by the specifications, render
      the value of the alt attribute. On the other hand, the src attribute is
      required even at the syntactic level (the DTD), so strictly speaking the
      specifications don't say what should happen - the document is in error,
      and error processing (if any) is up to the browser.
      [color=blue]
      > <td height=7><img width=1 height=1 alt=""></td>[/color]

      The apparent purpose is to make sure browsers don't treat the cell as
      empty (which would cause some undesidered effect, like suppression of
      background color).
      [color=blue]
      > OK, I have been known to resort to <td ...>&nbsp;</td> in the past,
      > but I don't think I'd really want to do that.[/color]

      And it has the drawback that the cell cannot become arbitrarily small,
      since the no-break space is treated as a character, occupying the same
      height as other characters in the current font.

      The usual trick is to use an img element with a src attribute that points
      to a transparent single-pixel GIF image. I don't see any benefits that
      the omission of an src attribute would have, apart from saving a little
      typing or copying. I have no idea why Google has chosen the sloppy way of
      using hacks.

      It is surprising that IE seems to treat an <img width=1 height=1 alt="">
      by not displaying anything (or perhaps just using a one pixel spacing).
      If the width and height attributes are omitted, the usual symbol for
      broken image is shown. The same happens if the attribute values are
      "sufficient ly" large. I get that symbol for width="10" but not for
      width="9" (tested with a few different font sizes, so I guess it does not
      depend on font size).

      --
      Yucca, http://www.cs.tut.fi/~jkorpela/
      Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

      Comment

      • Lachlan Hunt

        #4
        Re: img without src= (?!)

        Alan J. Flavell wrote:[color=blue]
        > For quite some other reason, I was looking at the source of a Google
        > response page (which by the way contains some horrible SGML-related
        > syntax errors), and was a bit surprised to find some <img> tags with
        > no src= attribute. They also show up in Mozilla's View->Page
        > Info->Media display, in that they have Type "Image" but the "Address"
        > column is empty.
        >
        > They use them like this:
        >
        > <td height=7><img width=1 height=1 alt=""></td>[/color]

        Hmmm... Interesting. A /spacer gif/, without the *spacer.gif*! It's
        definitely invalid, the src attributes is required, as stated in the DTD.

        <!ATTLIST IMG
        %attrs; -- %coreattrs, %i18n, %events --
        src %URI; #REQUIRED -- URI of image to embed --
        ...

        Though, it's strange that they actually decided to include the required
        alt attribute‽
        [color=blue]
        > What do the team think?[/color]

        It's not the worst atrocity Google has committed in their markup, but it
        is quite funny. I knew they broke every other rule in the book, such as
        using tables for layout, blockquote for indentation, unencoded
        ampersands in URIs, markup above the DOCTYPE and <html> (when viewing
        cached pages) etc… but this one is new to me, I've never seen anyone do
        that before.
        [color=blue]
        > OK, I have been known to resort to <td ...>&nbsp;</td> in the past,[/color]

        Well, there can be legitimate structural and semantic reasons for doing
        that if a table of data requires an empty cell, though I would have
        thought that just using <td></td> would be acceptable in those cases.
        If the reason is purely presentational, then it's not acceptable.

        Does anyone know the reason why editors, such as Dreamweaver, include an
        &nbsp; in empty cells like that by default? Is it for compatibility
        with older UAs or something?

        --
        Lachlan Hunt


        Please direct all spam to abuse@127.0.0.1
        Thank you.

        Comment

        • Philipp Lenssen

          #5
          Re: img without src= (?!)

          Lachlan Hunt wrote:
          [color=blue][color=green]
          > > OK, I have been known to resort to <td ...>&nbsp;</td> in the past,[/color]
          >
          > Well, there can be legitimate structural and semantic reasons for
          > doing that if a table of data requires an empty cell, though I would
          > have thought that just using <td></td> would be acceptable in those
          > cases. If the reason is purely presentational, then it's not
          > acceptable.[/color]

          I always include the non-breaking space in table cells too. I thought
          it was needed (DTD? Browser handling? Netscape 4...?). You know, other
          people don't even make their cells match (e.g. 4 colums in the first
          row, 3 in the second, 8 in the next... no colspan either... that's the
          sort of HTML I often have to work on).

          --
          Google Blogoscoped
          A daily news blog and community covering Google, search, and technology.

          Comment

          • Alan J. Flavell

            #6
            Re: img without src= (?!)

            On Fri, 13 Aug 2004, Lachlan Hunt wrote:
            [color=blue]
            > Does anyone know the reason why editors, such as Dreamweaver, include an
            > &nbsp; in empty cells like that by default?[/color]

            If you just code <td> </td> (or the same with th) then you'll find
            quite a few browser/versions which omit border, background colour etc.
            of the empty cell.

            Comment

            • Spartanicus

              #7
              Re: img without src= (?!)

              "Alan J. Flavell" <flavell@ph.gla .ac.uk> wrote:
              [color=blue][color=green]
              >> Does anyone know the reason why editors, such as Dreamweaver, include an
              >> &nbsp; in empty cells like that by default?[/color]
              >
              >If you just code <td> </td> (or the same with th) then you'll find
              >quite a few browser/versions which omit border, background colour etc.
              >of the empty cell.[/color]

              Most support table{empty-cells:show}, as per usual IE doesn't, which imo
              justifies the &nbsp; hack.

              Btw, which browsers don't show the background colour?

              --
              Spartanicus

              Comment

              • Brian

                #8
                Re: img without src= (?!)

                Lachlan Hunt wrote:
                [color=blue]
                > It's not the worst atrocity Google has committed in their markup,[/color]

                The strange thing is that much of the markup bloat seems to do
                absolutely nothing. There are nested tabled that could be done with
                <div> elements instead, saving characters and God only knows how much
                money in bandwith.
                [color=blue]
                > Does anyone know the reason why editors, such as Dreamweaver, include
                > an &nbsp; in empty cells like that by default?[/color]

                No. But I have just such construct in form that uses S. Poley's
                excellent js form validation. The documentation in the script says some
                browsers have trouble if you try to add a text node to an empty <td>
                element, so it should include &nbsp;.

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

                Comment

                • Harlan Messinger

                  #9
                  Re: img without src= (?!)


                  "Lachlan Hunt" <lachlan.hunt@l achy.id.au.inva lid> wrote in message
                  news:UZ3Tc.5536 6$K53.5863@news-server.bigpond. net.au...[color=blue]
                  > Alan J. Flavell wrote:[color=green]
                  > > For quite some other reason, I was looking at the source of a Google
                  > > response page (which by the way contains some horrible SGML-related
                  > > syntax errors), and was a bit surprised to find some <img> tags with
                  > > no src= attribute. They also show up in Mozilla's View->Page
                  > > Info->Media display, in that they have Type "Image" but the "Address"
                  > > column is empty.
                  > >
                  > > They use them like this:
                  > >
                  > > <td height=7><img width=1 height=1 alt=""></td>[/color]
                  >
                  > Hmmm... Interesting. A /spacer gif/, without the *spacer.gif*! It's
                  > definitely invalid, the src attributes is required, as stated in the DTD.
                  >
                  > <!ATTLIST IMG
                  > %attrs; -- %coreattrs, %i18n, %events --
                  > src %URI; #REQUIRED -- URI of image to embed --
                  > ...
                  >
                  > Though, it's strange that they actually decided to include the required
                  > alt attribute‽
                  >[color=green]
                  > > What do the team think?[/color]
                  >
                  > It's not the worst atrocity Google has committed in their markup, but it
                  > is quite funny. I knew they broke every other rule in the book, such as
                  > using tables for layout, blockquote for indentation, unencoded
                  > ampersands in URIs, markup above the DOCTYPE and <html> (when viewing
                  > cached pages) etc… but this one is new to me, I've never seen anyone do
                  > that before.
                  >[color=green]
                  > > OK, I have been known to resort to <td ...>&nbsp;</td> in the past,[/color]
                  >
                  > Well, there can be legitimate structural and semantic reasons for doing
                  > that if a table of data requires an empty cell, though I would have
                  > thought that just using <td></td> would be acceptable in those cases.
                  > If the reason is purely presentational, then it's not acceptable.[/color]

                  Depends what you mean by "acceptable "--see below.
                  [color=blue]
                  >
                  > Does anyone know the reason why editors, such as Dreamweaver, include an
                  > &nbsp; in empty cells like that by default? Is it for compatibility
                  > with older UAs or something?[/color]

                  No, it's the only way to deal with the treatment of empty cells in all the
                  graphical browsers I have: Netscape 4.7, IE 6, and current versions of
                  Mozilla, Firebird, and Opera. In the absence of special treatment with CSS,
                  all of these browsers represent tables by default with separated cell
                  borders, and *all* of them omit a cell's border if the cell is empty. Maybe
                  somebody considers this a feature, but I consider it a bug--an empty cell is
                  still supposed to look like a cell. Sticking &nbsp; into a cell makes the
                  cell's border appear in all of the above browsers.

                  The same result is achieved in CSS2-compliant browsers by using empty-cells:
                  show. This doesn't work in Netscape 4.7 or IE6.

                  See http://gavelcade.com/tests/empty-cells.html.

                  [color=blue]
                  >
                  > --
                  > Lachlan Hunt
                  > http://www.lachy.id.au/
                  >
                  > Please direct all spam to abuse@127.0.0.1
                  > Thank you.[/color]

                  Comment

                  • Harlan Messinger

                    #10
                    Re: img without src= (?!)


                    "Harlan Messinger" <h.messinger@co mcast.net> wrote in message
                    news:2o44alF6n8 v4U1@uni-berlin.de...[color=blue]
                    >
                    > "Lachlan Hunt" <lachlan.hunt@l achy.id.au.inva lid> wrote in message
                    > news:UZ3Tc.5536 6$K53.5863@news-server.bigpond. net.au...[color=green]
                    > > Alan J. Flavell wrote:[color=darkred]
                    > > > For quite some other reason, I was looking at the source of a Google
                    > > > response page (which by the way contains some horrible SGML-related
                    > > > syntax errors), and was a bit surprised to find some <img> tags with
                    > > > no src= attribute. They also show up in Mozilla's View->Page
                    > > > Info->Media display, in that they have Type "Image" but the "Address"
                    > > > column is empty.
                    > > >
                    > > > They use them like this:
                    > > >
                    > > > <td height=7><img width=1 height=1 alt=""></td>[/color]
                    > >
                    > > Hmmm... Interesting. A /spacer gif/, without the *spacer.gif*! It's
                    > > definitely invalid, the src attributes is required, as stated in the[/color][/color]
                    DTD.[color=blue][color=green]
                    > >
                    > > <!ATTLIST IMG
                    > > %attrs; -- %coreattrs, %i18n, %events --
                    > > src %URI; #REQUIRED -- URI of image to embed --
                    > > ...
                    > >
                    > > Though, it's strange that they actually decided to include the required
                    > > alt attribute‽
                    > >[color=darkred]
                    > > > What do the team think?[/color]
                    > >
                    > > It's not the worst atrocity Google has committed in their markup, but it
                    > > is quite funny. I knew they broke every other rule in the book, such as
                    > > using tables for layout, blockquote for indentation, unencoded
                    > > ampersands in URIs, markup above the DOCTYPE and <html> (when viewing
                    > > cached pages) etc… but this one is new to me, I've never seen anyone do
                    > > that before.
                    > >[color=darkred]
                    > > > OK, I have been known to resort to <td ...>&nbsp;</td> in the past,[/color]
                    > >
                    > > Well, there can be legitimate structural and semantic reasons for doing
                    > > that if a table of data requires an empty cell, though I would have
                    > > thought that just using <td></td> would be acceptable in those cases.
                    > > If the reason is purely presentational, then it's not acceptable.[/color]
                    >
                    > Depends what you mean by "acceptable "--see below.
                    >[color=green]
                    > >
                    > > Does anyone know the reason why editors, such as Dreamweaver, include an
                    > > &nbsp; in empty cells like that by default? Is it for compatibility
                    > > with older UAs or something?[/color]
                    >
                    > No, it's the only way to deal with the treatment of empty cells in all the
                    > graphical browsers I have: Netscape 4.7, IE 6, and current versions of
                    > Mozilla, Firebird, and Opera. In the absence of special treatment with[/color]
                    CSS,[color=blue]
                    > all of these browsers represent tables by default with separated cell
                    > borders, and *all* of them omit a cell's border if the cell is empty.[/color]
                    Maybe[color=blue]
                    > somebody considers this a feature, but I consider it a bug--an empty cell[/color]
                    is[color=blue]
                    > still supposed to look like a cell. Sticking &nbsp; into a cell makes the
                    > cell's border appear in all of the above browsers.
                    >
                    > The same result is achieved in CSS2-compliant browsers by using[/color]
                    empty-cells:[color=blue]
                    > show. This doesn't work in Netscape 4.7 or IE6.
                    >
                    > See http://gavelcade.com/tests/empty-cells.html.[/color]

                    Argh--I had forgotten to include the doctype, so all was in quirks mode.
                    When I added the strict doctype, Mozilla and Firebird showed empty cells as
                    I think they should look--with borders--even without &nbsp; or explicit
                    empty-cells: show. Opera, IE 6, and Netscape 4.7 still display the page as
                    before. The updated version is posted.

                    Comment

                    • Sam Hughes

                      #11
                      Re: img without src= (?!)

                      "Harlan Messinger" <h.messinger@co mcast.net> wrote in
                      news:2o44alF6n8 v4U1@uni-berlin.de:
                      [color=blue]
                      > In the absence of special
                      > treatment with CSS, all of these browsers represent tables by
                      > default with separated cell borders, and *all* of them omit a cell's
                      > border if the cell is empty.[/color]

                      ~pops in to point out that by default, they display no border at all.~

                      --
                      How to make it so visitors can't resize your fonts:
                      <http://www.rpi.edu/~hughes/www/wise_guy/unresizable_tex t.html>

                      Comment

                      • Harlan Messinger

                        #12
                        Re: img without src= (?!)


                        "Sam Hughes" <hughes@rpi.edu > wrote in message
                        news:Xns9544762 8B4342hughesrpi edu@130.133.1.4 ...[color=blue]
                        > "Harlan Messinger" <h.messinger@co mcast.net> wrote in
                        > news:2o44alF6n8 v4U1@uni-berlin.de:
                        >[color=green]
                        > > In the absence of special
                        > > treatment with CSS, all of these browsers represent tables by
                        > > default with separated cell borders, and *all* of them omit a cell's
                        > > border if the cell is empty.[/color]
                        >
                        > ~pops in to point out that by default, they display no border at all.~[/color]

                        I meant, if you have border="1" in the table tag!

                        Comment

                        • Sam Hughes

                          #13
                          Re: img without src= (?!)

                          "Harlan Messinger" <h.messinger@co mcast.net> wrote in news:2o45muF6iq f4U1
                          @uni-berlin.de:
                          [color=blue]
                          >
                          > "Sam Hughes" <hughes@rpi.edu > wrote in message
                          > news:Xns9544762 8B4342hughesrpi edu@130.133.1.4 ...[color=green]
                          >> "Harlan Messinger" <h.messinger@co mcast.net> wrote in
                          >> news:2o44alF6n8 v4U1@uni-berlin.de:
                          >>[color=darkred]
                          >> > In the absence of special
                          >> > treatment with CSS, all of these browsers represent tables by
                          >> > default with separated cell borders, and *all* of them omit a cell's
                          >> > border if the cell is empty.[/color]
                          >>
                          >> ~pops in to point out that by default, they display no border at all.~[/color]
                          >
                          > I meant, if you have border="1" in the table tag![/color]

                          Yah, I just noticed that I got confused for a second, so I decided that
                          maybe I'd like to clear that up :)


                          --
                          How to make it so visitors can't resize your fonts:
                          <http://www.rpi.edu/~hughes/www/wise_guy/unresizable_tex t.html>

                          Comment

                          • Harlan Messinger

                            #14
                            Re: img without src= (?!)


                            "Harlan Messinger" <h.messinger@co mcast.net> wrote in message
                            news:2o458iF6fi aiU1@uni-berlin.de...[color=blue]
                            >
                            > "Harlan Messinger" <h.messinger@co mcast.net> wrote in message
                            > news:2o44alF6n8 v4U1@uni-berlin.de...[color=green]
                            > >
                            > > "Lachlan Hunt" <lachlan.hunt@l achy.id.au.inva lid> wrote in message
                            > > news:UZ3Tc.5536 6$K53.5863@news-server.bigpond. net.au...[color=darkred]
                            > > > Alan J. Flavell wrote:
                            > > > > For quite some other reason, I was looking at the source of a Google
                            > > > > response page (which by the way contains some horrible SGML-related
                            > > > > syntax errors), and was a bit surprised to find some <img> tags with
                            > > > > no src= attribute. They also show up in Mozilla's View->Page
                            > > > > Info->Media display, in that they have Type "Image" but the[/color][/color][/color]
                            "Address"[color=blue][color=green][color=darkred]
                            > > > > column is empty.
                            > > > >
                            > > > > They use them like this:
                            > > > >
                            > > > > <td height=7><img width=1 height=1 alt=""></td>
                            > > >
                            > > > Hmmm... Interesting. A /spacer gif/, without the *spacer.gif*! It's
                            > > > definitely invalid, the src attributes is required, as stated in the[/color][/color]
                            > DTD.[color=green][color=darkred]
                            > > >
                            > > > <!ATTLIST IMG
                            > > > %attrs; -- %coreattrs, %i18n,[/color][/color][/color]
                            %events --[color=blue][color=green][color=darkred]
                            > > > src %URI; #REQUIRED -- URI of image to embed --
                            > > > ...
                            > > >
                            > > > Though, it's strange that they actually decided to include the[/color][/color][/color]
                            required[color=blue][color=green][color=darkred]
                            > > > alt attribute‽
                            > > >
                            > > > > What do the team think?
                            > > >
                            > > > It's not the worst atrocity Google has committed in their markup, but[/color][/color][/color]
                            it[color=blue][color=green][color=darkred]
                            > > > is quite funny. I knew they broke every other rule in the book, such[/color][/color][/color]
                            as[color=blue][color=green][color=darkred]
                            > > > using tables for layout, blockquote for indentation, unencoded
                            > > > ampersands in URIs, markup above the DOCTYPE and <html> (when viewing
                            > > > cached pages) etc… but this one is new to me, I've never seen anyone[/color][/color][/color]
                            do[color=blue][color=green][color=darkred]
                            > > > that before.
                            > > >
                            > > > > OK, I have been known to resort to <td ...>&nbsp;</td> in the past,
                            > > >
                            > > > Well, there can be legitimate structural and semantic reasons for[/color][/color][/color]
                            doing[color=blue][color=green][color=darkred]
                            > > > that if a table of data requires an empty cell, though I would have
                            > > > thought that just using <td></td> would be acceptable in those cases.
                            > > > If the reason is purely presentational, then it's not acceptable.[/color]
                            > >
                            > > Depends what you mean by "acceptable "--see below.
                            > >[color=darkred]
                            > > >
                            > > > Does anyone know the reason why editors, such as Dreamweaver, include[/color][/color][/color]
                            an[color=blue][color=green][color=darkred]
                            > > > &nbsp; in empty cells like that by default? Is it for compatibility
                            > > > with older UAs or something?[/color]
                            > >
                            > > No, it's the only way to deal with the treatment of empty cells in all[/color][/color]
                            the[color=blue][color=green]
                            > > graphical browsers I have: Netscape 4.7, IE 6, and current versions of
                            > > Mozilla, Firebird, and Opera. In the absence of special treatment with[/color]
                            > CSS,[color=green]
                            > > all of these browsers represent tables by default with separated cell
                            > > borders, and *all* of them omit a cell's border if the cell is empty.[/color]
                            > Maybe[color=green]
                            > > somebody considers this a feature, but I consider it a bug--an empty[/color][/color]
                            cell[color=blue]
                            > is[color=green]
                            > > still supposed to look like a cell. Sticking &nbsp; into a cell makes[/color][/color]
                            the[color=blue][color=green]
                            > > cell's border appear in all of the above browsers.
                            > >
                            > > The same result is achieved in CSS2-compliant browsers by using[/color]
                            > empty-cells:[color=green]
                            > > show. This doesn't work in Netscape 4.7 or IE6.
                            > >
                            > > See http://gavelcade.com/tests/empty-cells.html.[/color]
                            >
                            > Argh--I had forgotten to include the doctype, so all was in quirks mode.
                            > When I added the strict doctype, Mozilla and Firebird showed empty cells[/color]
                            as[color=blue]
                            > I think they should look--with borders--even without &nbsp; or explicit
                            > empty-cells: show. Opera, IE 6, and Netscape 4.7 still display the page as
                            > before. The updated version is posted.[/color]

                            Argh again--if I'm using border="1", I can't have a strict doctype. But you
                            get the idea.

                            Comment

                            • Spartanicus

                              #15
                              Re: img without src= (?!)

                              "Harlan Messinger" <h.messinger@co mcast.net> wrote:

                              Kindly learn how to snip quotes.
                              [color=blue]
                              >Argh again--if I'm using border="1", I can't have a strict doctype.[/color]

                              The border attribute on the table element is not deprecated.

                              --
                              Spartanicus

                              Comment

                              Working...