0

I'm curious, does XML standard allow me to write tags without content as one tag?

I'll give you 2 examples:

Can I interchange <img alt="foo" /> with <img alt="foo"></img> ? Or can I interchange the tag implying and empty message <message></message> with just a simple <message /> tag?

In the answer could you please quote the spec or show the source?

Novellizator
  • 13,633
  • 9
  • 43
  • 65
  • You have tagged with `html` and `xhtml`. These are conflicting tags. Pick one. Anyway, `` and `` "should" be treated the same in XML (and thus XHTML), but it's possible for a particular XML consumer to do otherwise .. however, HTML is *not* XML. –  Feb 22 '13 at 10:02

2 Answers2

2

As long as you are talking about XML or XHTML, then the two forms are equivalent. In both HTML4 and HTML5 however, they are not.

Community
  • 1
  • 1
Jon
  • 428,835
  • 81
  • 738
  • 806
1

Yes You can do that. As long as the XML is valid you can do that.

Sanober Malik
  • 2,765
  • 23
  • 30