Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > img tag in XHTML strict

Reply
Thread Tools

img tag in XHTML strict

 
 
tochiromifune
Guest
Posts: n/a
 
      01-13-2006
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
 
Reply With Quote
 
 
 
 
David Dorward
Guest
Posts: n/a
 
      01-13-2006
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
 
Reply With Quote
 
 
 
 
Els
Guest
Posts: n/a
 
      01-13-2006
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 -
 
Reply With Quote
 
Andy Dingley
Guest
Posts: n/a
 
      01-13-2006
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.
 
Reply With Quote
 
Jukka K. Korpela
Guest
Posts: n/a
 
      01-13-2006
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


 
Reply With Quote
 
Els
Guest
Posts: n/a
 
      01-14-2006
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 -
 
Reply With Quote
 
Neredbojias
Guest
Posts: n/a
 
      01-14-2006
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.
 
Reply With Quote
 
Leif K-Brooks
Guest
Posts: n/a
 
      01-15-2006
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?
 
Reply With Quote
 
Els
Guest
Posts: n/a
 
      01-15-2006
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 -
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do u invoke Tag b's Tag Handler from within Tag a's tag Handler? shruds Java 1 01-27-2006 03:00 AM
how to download img from html img tag news.austin.rr.com ASP .Net 2 04-27-2005 06:25 PM
Re: img tag XSLT-&gt;XHTML irsan XML 1 05-16-2004 04:27 PM
img tag XSLT->XHTML full_philNO@SPAMyahooPLEASE.fr XML 2 05-16-2004 04:24 PM
img alignment in xhtml strict and css Kelwin Delaunay HTML 4 04-17-2004 05:41 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57