473,791 Members | 3,277 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Empty Elements in XHTML

Hi everyone,

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

Example:

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

August
Mar 11 '07 #1
3 2107
August Karlstrom wrote:
In XHTML, can any empty element <foo></foobe 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 interoperabilit y, 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></tdand only elements defined as being empty (such
as the br element) as <br />.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Mar 11 '07 #2
Martin Honnen skrev:
August Karlstrom wrote:
>In XHTML, can any empty element <foo></foobe 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 interoperabilit y, 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></tdand only elements defined as being empty (such
as the br element) as <br />.
OK, thanks for the accurate answer.
August
Mar 11 '07 #3
On 11 Mar, 16:14, August Karlstrom <fusionf...@com hem.sewrote:
In XHTML, can any empty element <foo></foobe 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>, <hretc.) 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.

Mar 12 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2874
by: Derek Basch | last post by:
Hello All, I ran into a problem while dynamically constructing XHTML documents using minidom. If you create a script tag such as: script_node_0 = self.doc.createElement("script") script_node_0.setAttribute("type", "text/javascript") script_node_0.setAttribute("src", "../test.js") minidom renders it as:
13
3405
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to <foo/>) From XHTML specification:
18
2436
by: Tjerk Wolterink | last post by:
i have the following rule, <xsl:template match="br"> <br/> </xsl:template> This should convert all <br/> to <br/> but, my transformer transforms it all to
18
2477
by: Neal | last post by:
According to the specs (http://www.w3.org/TR/html401/struct/links.html#h-12.2), the <a> element requires an end tag. And so, when we use <A NAME="foo"> in HTML 2.0 to 4.01, it won't validate, it'll want to find the </A> tag. However, when I write a document containing, say, <a name="foo" /> it validates in XHTML 1.0. I'm obviously missing something here, as this confuses me somewhat. Does the magical / make the empty a element valid?...
1
1656
by: Mark | last post by:
(I'm new to these groups, so I'm not sure which one to use ...) XHTML has been emabled in virtually all modern browsers. So is there any more need for the space before the closing tags in empty elements? The following seems to work for me in the browser's I've got: <br/> I no longer have IE 5, but do a significant enough number of users still
12
17116
by: Stefan Weiss | last post by:
Hi. (this is somewhat similar to yesterday's thread about empty links) I noticed that Tidy issues warnings whenever it encounters empty tags, and strips those tags if cleanup was requested. This is okay in some cases (such as <tbody>), but problematic for other tags (such as <option>). Some tags (td, th, ...) do not produce warnings when they are empty.
2
1574
by: Simon Brooke | last post by:
I have a document type which I'm developing and working with, which is currently defined in a DTD, mainly because I still haven't really learned to use schemas. In this document type I need to specify that some specific elements may have children which are XHTML %Flow; elements. It isn't valid for these elements to contain arbitrary XHTML, and it isn't valid for other elements in my language to have any XHTML children. I presume I can't...
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9517
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9997
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9030
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4110
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.