Click to See Complete Forum and Search --> : xhtml strict validation


moondance
12-20-2003, 12:40 PM
i'm trying to validate my page with xhtml strict and keep on getting the message:

"end tag for "xxx" omitted, but OMITTAG NO was specified"

where xx is either img or link.

heres a sample line:

<td>
<a href = "#"><img src="graphics/2_tnail.jpg" width="158px" height="140px" onclick="popimage('graphics/2.jpg',660,510);return false"></a>
</td>

what does this mean and how do i get it right?

fredmv
12-20-2003, 12:43 PM
Try this:<td>
<a href="#"><img src="graphics/2_tnail.jpg" alt="" style="width: 158px; height: 140px;" onclick="popimage('graphics/2.jpg',660,510);return false" /></a>
</td>You must close all tags when using an XHTML DOCTYPE. Even the "empty" tags (such as <img>, <input>, etc.) by adding a trailing slash onto the end of it. Also, as in previous DOCTYPEs, all <img> elements require the alt attribute.

moondance
12-20-2003, 12:44 PM
so what other tags do i need to add that extra ending slash to?

fredmv
12-20-2003, 12:46 PM
All "empty" tags — these kind of tags are the tags in which don't have a matching closing tag. For example, <h1> is not an "empty" tag since it has a closing tag:<h1>foo</h1>But, <input> is since it doesn't, therefore you add a trailing slash in order to close it:<input type="text" value="foo" />

moondance
12-20-2003, 12:49 PM
ohhh i see. so where <img> doesn't go as <img> </img> you need to a closing tag as <img /> yeah?


thanks for your help
:D

fredmv
12-20-2003, 12:58 PM
That's absolutely correct. You're welcome. :D

Funky Monk
07-01-2005, 09:12 AM
Hi. I have a similar problem. I use a PHP script to add images dynamically from a MySQL database. The code I'm using is:

<img src="<?php echo $row_rsShowNews['../thumbnail']; ?>" alt="<?php echo $row_rsShowNews['thumbnail_alt']; ?>" name="thumbnail_image" id="thumbnail_image" />

As you can see from this I am closing the tag correctly but when I look at the source code of a page it is displayed as:

<img name="thumbnail_image" src="/news-management/uploaded-images/angola.gif" alt="Flag">

It omits the closing />. Is there any way of getting this to validate??

justa messenger
05-13-2009, 02:00 PM
hi just a quick question, i see that all the code i find when i research has a space just before the / in the tag.
<img />
is there a reason for this? right now all my tags are <img/> and i don't know if i should change them to <img />.
thx in advance for any response.

Charles
05-13-2009, 02:13 PM
XHTML has an embarrassing little problem. It's not compatible with HTML. Things like <img/> and <script/> are both perfectly good XHTML but will cause problems when treated as HTML or viewed on an HTML browser. If your goal is XHTML then go ahead and omit that space. If you need this to work in browsers then you're better off just using HTML 4.01 Strict. If you really, really do need this to be XHTML but still work as HTML then you need to use the XHTML/HTML hybrid described in the XHTML 1.0 spec and see http://www.w3.org/TR/xhtml1/#guidelines .