Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Empty Elements in XHTML

Reply
Thread Tools

Empty Elements in XHTML

 
 
August Karlstrom
Guest
Posts: n/a
 
      03-11-2007
Hi everyone,

In XHTML, can any empty element <foo></foo> be replaced by <foo />?

Example:

<table>
<tr><td>1</td><td>2</td></tr>
<tr><td /><td>4</td></tr>
</table>


Regards,

August
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      03-11-2007
August Karlstrom wrote:

> In XHTML, can any empty element <foo></foo> be replaced by <foo />?
>
> Example:
>
> <table>
> <tr><td>1</td><td>2</td></tr>
> <tr><td /><td>4</td></tr>
> </table>


If parsed as XML it will not matter whether you have
<td></td>
or
<td />
or
<td/>

On the other hand the XML 1.0 specification says
"For interoperability, the empty-element tag SHOULD be used, and
SHOULD only be used, for elements which are declared EMPTY."
so as td elements are not declared as empty".
That is also what the XHTML 1.0 specification suggests if you want to
serve XHTML 1.0 documents as text/html. In that case you markup an empty
table cell as <td></td> and only elements defined as being empty (such
as the br element) as <br />.

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
August Karlstrom
Guest
Posts: n/a
 
      03-11-2007
Martin Honnen skrev:
> August Karlstrom wrote:
>
>> In XHTML, can any empty element <foo></foo> be replaced by <foo />?
>>
>> Example:
>>
>> <table>
>> <tr><td>1</td><td>2</td></tr>
>> <tr><td /><td>4</td></tr>
>> </table>

>
> If parsed as XML it will not matter whether you have
> <td></td>
> or
> <td />
> or
> <td/>
>
> On the other hand the XML 1.0 specification says
> "For interoperability, the empty-element tag SHOULD be used, and
> SHOULD only be used, for elements which are declared EMPTY."
> so as td elements are not declared as empty".
> That is also what the XHTML 1.0 specification suggests if you want to
> serve XHTML 1.0 documents as text/html. In that case you markup an empty
> table cell as <td></td> and only elements defined as being empty (such
> as the br element) as <br />.
>


OK, thanks for the accurate answer.


August
 
Reply With Quote
 
Andy Dingley
Guest
Posts: n/a
 
      03-12-2007
On 11 Mar, 16:14, August Karlstrom <fusionf...@comhem.se> wrote:

> In XHTML, can any empty element <foo></foo> be replaced by <foo />?


What's "XHTML" here?

If you mean "XHTML as XML", then of course they're absolutely
identical. However you can't use XHTML as XML on today's web (an FAQ
in c.i.w.a.h)

if you mean "Appendix C XHTML" so as to make it usable on the web,
then they're different and must be kept distinct. XML sees "empty
elements" as those with no current content at that time. HTML sees
"empty elements" as those defined as empty in ther DTD (e.g. <img>,
<br>, <hr> etc.) These _defined_ empty elements should be serialised
as <br /> but non-empty elements with no content must remain as start
and end tags, e.g. <script src="foo.js" ></script>

There's a huge amount of past discussion of this in c.i.w.a.h, some of
it's even accurate.

 
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
Should I Convert Site To XHTML or XHTML mobile? chronos3d HTML 9 12-05-2006 04:46 PM
parse URL (href) from xhtml, xhtml -> text, for data hawat.thufir@gmail.com XML 7 02-08-2006 07:39 PM
Altova Mapforce - xml 2 xml map: empty elements output although input element is not empty Lukas XML 3 11-10-2005 02:25 PM
Migrating to XHTML: empty elements Mark HTML 7 07-09-2005 12:01 PM
XHTML user agent behavior regarding empty elements Mikko Ohtamaa XML 13 09-02-2003 01:56 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