img tag in XHTML strict

Discussion in 'HTML' started by tochiromifune, Jan 13, 2006.

  1. Hello,

    My page fails the W3C validation test because my <img> tags are not
    included in block level tags. Does that mean I must write:
    <p><img src="" alt="" /></p>
    instead of
    <img src="" alt="" />

    ??

    Thank you for your help
    tochiromifune, Jan 13, 2006
    #1
    1. Advertising

  2. tochiromifune wrote:

    > My page fails the W3C validation test because my <img> tags are not
    > included in block level tags. Does that mean I must write:
    > <p><img src="" alt="" /></p>
    > instead of
    > <img src="" alt="" />


    An image where the alternative text is a null string is unlikely to be a
    paragraph. A div is more likely to be the most appropriate markup.

    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
    David Dorward, Jan 13, 2006
    #2
    1. Advertising

  3. tochiromifune

    Els Guest

    David Dorward wrote:

    > tochiromifune wrote:
    >
    >> My page fails the W3C validation test because my <img> tags are not
    >> included in block level tags. Does that mean I must write:
    >> <p><img src="" alt="" /></p>
    >> instead of
    >> <img src="" alt="" />

    >
    > An image where the alternative text is a null string is unlikely to be a
    > paragraph. A div is more likely to be the most appropriate markup.


    If you just enclose your entire page in one div, it might save you
    some code, depending on how many loose images you have in it.

    --
    Els http://locusmeus.com/
    Sonhos vem. Sonhos vão. O resto é imperfeito.
    - Renato Russo -
    Els, Jan 13, 2006
    #3
  4. tochiromifune

    Andy Dingley Guest

    On 13 Jan 2006 21:05:12 GMT, tochiromifune <> wrote:

    >My page fails the W3C validation test because my <img> tags are not
    >included in block level tags. Does that mean I must write:
    ><p><img src="" alt="" /></p>
    >instead of
    ><img src="" alt="" />


    Probably <div>img src="" alt="" /></div> is better, but you're basically
    right.

    If it was reasonable to put <img> into a <p>, you'd probably already
    have done it. If you want something that's more "anonymous" (for a
    free-floating image not connected with any text), then use a <div>.
    You might also wish to put a class on all these img-container <div>s,
    just so you can easily control their CSS properties.
    Andy Dingley, Jan 13, 2006
    #4
  5. Els <> wrote:

    > If you just enclose your entire page in one div, it might save you
    > some code, depending on how many loose images you have in it.


    You save more code by using HTML 4.01 Transitional, which allows "loose"
    content inside body and does not require all end tags.

    If you wish to comply with a Strict DOCTYPE, then it's rather pointless to
    use <body><div>...</div></body>, since the _idea_ in Strict is to put text
    and inline markup inside _suitable_ blocks. If you don't care about the idea,
    you could use Transitional, which does not require the pointless
    <div> and </div> tags.

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
    Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html
    Jukka K. Korpela, Jan 13, 2006
    #5
  6. tochiromifune

    Els Guest

    Jukka K. Korpela wrote:

    > Els <> wrote:
    >
    >> If you just enclose your entire page in one div, it might save you
    >> some code, depending on how many loose images you have in it.

    >
    > You save more code by using HTML 4.01 Transitional, which allows "loose"
    > content inside body and does not require all end tags.
    >
    > If you wish to comply with a Strict DOCTYPE, then it's rather pointless to
    > use <body><div>...</div></body>, since the _idea_ in Strict is to put text
    > and inline markup inside _suitable_ blocks. If you don't care about the idea,
    > you could use Transitional, which does not require the pointless
    > <div> and </div> tags.


    You're probably right about the Strict rules, but I think that having
    loose images in a page isn't quite the same as switching to
    Transitional altogether.
    I always have my pages in a div, simply because I like to have the
    option to add a border, a margin. I always have <body><div
    id="container">....</div></body>
    Often I give that container a left and right margin and a border
    colour, or even a shadow effect.

    And if I then have some decorative images floated left and right
    within the content, I really don't see the problem if there isn't a
    <div></div> around them. I think the rule that images and inline
    content should be inside suitable blocks, wasn't invented for floating
    decorative images, but for semantics. Decorative images aren't
    semantic by definition, but because of the <img> element, they are
    caught in the rule together with text that should be in paragraphs and
    inline images. I prefer to look at the whole of an idea, instead of
    scrutinously applying rigid rules without thinking about the reasons
    for those rules. Unless there is a compatibility or accessibility
    reason for putting decorative images in divs, I don't see the point,
    and I find switching to Transitional an over the top measure to allow
    loose images. Really, what's worse in your opinion: add a possibly
    superfluous div, or change to a doctype that allows a bunch of
    deprecated code?

    --
    Els http://locusmeus.com/
    Sonhos vem. Sonhos vão. O resto é imperfeito.
    - Renato Russo -
    Els, Jan 14, 2006
    #6
  7. tochiromifune

    Neredbojias Guest

    With neither quill nor qualm, Els quothed:

    > Jukka K. Korpela wrote:
    >
    > > Els <> wrote:
    > >
    > >> If you just enclose your entire page in one div, it might save you
    > >> some code, depending on how many loose images you have in it.

    > >
    > > You save more code by using HTML 4.01 Transitional, which allows "loose"
    > > content inside body and does not require all end tags.
    > >
    > > If you wish to comply with a Strict DOCTYPE, then it's rather pointless to
    > > use <body><div>...</div></body>, since the _idea_ in Strict is to put text
    > > and inline markup inside _suitable_ blocks. If you don't care about the idea,
    > > you could use Transitional, which does not require the pointless
    > > <div> and </div> tags.

    >
    > You're probably right about the Strict rules, but I think that having
    > loose images in a page isn't quite the same as switching to
    > Transitional altogether.
    > I always have my pages in a div, simply because I like to have the
    > option to add a border, a margin. I always have <body><div
    > id="container">....</div></body>
    > Often I give that container a left and right margin and a border
    > colour, or even a shadow effect.
    >
    > And if I then have some decorative images floated left and right
    > within the content, I really don't see the problem if there isn't a
    > <div></div> around them. I think the rule that images and inline
    > content should be inside suitable blocks, wasn't invented for floating
    > decorative images, but for semantics. Decorative images aren't
    > semantic by definition, but because of the <img> element, they are
    > caught in the rule together with text that should be in paragraphs and
    > inline images. I prefer to look at the whole of an idea, instead of
    > scrutinously applying rigid rules without thinking about the reasons
    > for those rules. Unless there is a compatibility or accessibility
    > reason for putting decorative images in divs, I don't see the point,
    > and I find switching to Transitional an over the top measure to allow
    > loose images. Really, what's worse in your opinion: add a possibly
    > superfluous div, or change to a doctype that allows a bunch of
    > deprecated code?


    I have (a few) pages where I don't use a doctype at all. Why? Simply
    because they work better, -tested in IE, Mozilla&Firefox, and Opera. Of
    course this is basically just "appealing to" quirks mode, but you and I
    have already discussed issues relating to the vertical centering of
    small content.

    Surprisingly (at least to me) is that with some markup Mozilla and Opera
    work better than IE even under this "quirks mode" auspices.

    --
    Neredbojias
    Contrary to popular belief, it is believable.
    Neredbojias, Jan 14, 2006
    #7
  8. Els wrote:
    > I always have my pages in a div, simply because I like to have the
    > option to add a border, a margin. I always have <body><div
    > id="container">....</div></body>


    You do realize that the body element can be styled, right?
    Leif K-Brooks, Jan 15, 2006
    #8
  9. tochiromifune

    Els Guest

    Leif K-Brooks wrote:

    > Els wrote:
    >> I always have my pages in a div, simply because I like to have the
    >> option to add a border, a margin. I always have <body><div
    >> id="container">....</div></body>

    >
    > You do realize that the body element can be styled, right?


    :)
    And you do realize that the combination of html and body element is
    much less manipulatable than the combination of html and body and div,
    right?

    --
    Els http://locusmeus.com/
    Sonhos vem. Sonhos vão. O resto é imperfeito.
    - Renato Russo -
    Els, Jan 15, 2006
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. news.austin.rr.com

    how to download img from html img tag

    news.austin.rr.com, Apr 27, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    505
    Steve C. Orr [MVP, MCSD]
    Apr 27, 2005
  2. shruds
    Replies:
    1
    Views:
    779
    John C. Bollinger
    Jan 27, 2006
  3. Kelwin Delaunay

    img alignment in xhtml strict and css

    Kelwin Delaunay, Apr 17, 2004, in forum: HTML
    Replies:
    4
    Views:
    10,829
    Kelwin Delaunay
    Apr 17, 2004
  4. Replies:
    2
    Views:
    4,485
    Philippe
    May 16, 2004
  5. irsan
    Replies:
    1
    Views:
    838
    Philippe
    May 16, 2004
Loading...

Share This Page